Monday, June 20, 2016

Your Own Custom Annotations – More than Just Comments!

In this article, we are going to look at how we can create and use our own custom annotations in a Symfony 3 application. You know annotations right? They are the docblock metadata/configuration we see above classes, methods and properties. You've most likely seen them used to declare Controller routes (@Route()) and Doctrine ORM mappings (@ORM()), or even to control access to various classes and methods in packages like Rauth. But have you ever wondered how can you use them yourself? How you can define your own annotation and then use it to read information about a class or method without actually loading it?

Snippet of code with custom annotations

Before we do this, a small disclaimer is in order. Annotations have nothing to do with Symfony. They are a concept developed as part of the Doctrine project to solve the problem of mapping ORM information to class methods.

In this article we are going to build a small reusable bundle called WorkerBundle. Reusable yes, but still only for demo purposes so not really package-able. We're going to develop a small concept that allows the definition of various Worker types which "operate" at various speeds and which can then be used by anyone in the application. The actual worker operations are outside the scope of this post, since we are focusing on setting up the system to manage them (and discover them via annotations).

To see where we're going, you can check out this repository and follow the instructions covered there for setting up the bundle in your local Symfony app.

The Workers

The workers will implement an interface that requires one method: ::work(). Inside our new WorkerBundle, let's create a Workers/ directory to keep things tidy and add the interface there:

<?php

namespace WorkerBundle\Workers;

interface WorkerInterface
{
    /**
     * Does the work
     *
     * @return NULL
     */
    public function work();
}

The Annotation

Each worker has to implement the above interface. That's clear. But aside from that, we need them to also have an annotation above the class in order to find them and read some metadata about them.

Doctrine maps the docblock annotation to a class whose properties represent the keys inside the annotation itself. Let's create our own and see this in practice.

Continue reading %Your Own Custom Annotations – More than Just Comments!%


by Daniel Sipos via SitePoint

Ara

opl-small

Landing Page promoting Google's upcoming modular phone called 'Ara'. Fitting to have a mixed block layout in the One Pager;) Final little shoutout to the dev application form, very slick.

by Rob Hope via One Page Love

What's New in Android N and Wear 2.0

Highlands to Islands

Highlands to Islands

Responsive One Pager with nice subtle textures promoting 'Highlands To Islands' - a multi use trail system. Thanks for the build notes!

by Rob Hope via One Page Love

Quick Tip: DRY Up Your Model Validations Tests

I was working on an application and needed to test the models, which is a pretty normal practice. I had to repeat validation tests for each field and each model resulting in lots of duplicated test code. So, I’m going to share my solution to this problem, which will help us avoid repeating similar validation tests for each model.

Continue reading %Quick Tip: DRY Up Your Model Validations Tests%


by Sarmad Sabih via SitePoint

Create a One Page website using the robust H-Code WordPress Theme

h-code-logoBig thanks to this weeks RSS feed and website sponsor, ThemeZaa, who have created the wonderful H-Code WordPress Theme.

H-Code‘ is a robust WordPress theme featuring multiple One Page layout options that cover several industries.

To give you an indication of the spread there are 11 different One Page layouts that include restaurant, fashion, architecture, spa, digital agency, corporate, travel agency, personal, wedding and of course the a standard long scrolling landing page.

ThemeZaa have also mixed up the features with the layouts giving your 26 One Page demos to browse and really experience the theme.


10 Reasons why H-Code is the right WordPress theme for you:

h-code-lamp

  1. Parallax & Video Backgrounds – Create an awesome first impression with parallax image backgrounds and videos to make your page alive and beautiful.
  2. Multi-use – 11 different industries covered makes this your go-to theme if you freelancer or have a digital agency.
  3. Quick setup – H-Code features one-click demo import of posts, pages, sliders, widgets, menus, sidebars, theme settings and more.
  4. Value for money – The theme includes the Slider Revolution plugin (valued at $19) and the Visual Composer plugin (valued at $34) to enable page building functionality. So your $59 theme purchase already includes $54 worth of premium plugins.
  5. Lifetime Free Updates – No annual renewals or licenses to keep getting theme updates.
  6. Commerce – Excellent to know the theme integrates into WooCommerce if needed too:)
  7. SEO – optimised for Search Engine Optimization including SEO plugin compatibility.
  8. Easy content editing – With Visual Composer included (free) there is drag and drop functionality.
  9. Useful shortcodes – The theme includes tons of shortcodes developed for all the different elements.
  10. Top Support – A rating of 4.71 out 5 stars after 500+ sales is an excellent rating. You know you are going to be looked after.

I’ve handpicked 3 of my favorite One Page demo’s from the H-Code theme:

Featured Demo: Restaurant

h-code-rest

Featured above is my favorite, the restaurant option. Just love how the ingredients individually slide in in the header – achieved by the Slider Revolution plugin – valued at $19 and bundled within the price.

Launch Demo
Visit Theme Page


Featured Demo: Digital Agency

h-code-digi

Lots of character in the intro followed by a slick Portfolio section with pop up big image gallery. Perfect for freelancers or digital agencies.

Launch Demo
Visit Theme Page


Featured Demo: Travel Agency

h-code-trav

Good to see theme companies tackling niches well. My favorite feature is the special offers slider further down the page. Very slick.

Launch Demo
Visit Theme Page


Don’t Need WordPress… there is an HTML version!

H-Code is a monster WordPress theme offering huge value for your $59 but it’s good to know there is also an HTML version for $20 if that’s all you’re after.

Thanks again to ThemeZaa for sponsored One Page Love this week – we really appreciate it!


by Rob Hope via One Page Love

Prelodr : Preloader inspired in Google Inbox

A simple Material preloader with javascript inspired in Google Inbox.

The post Prelodr : Preloader inspired in Google Inbox appeared first on jQuery Rain.


by Admin via jQuery Rain