Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Eleven Labs:
Use the Symfony Workflow Component
Sep 29, 2016 @ 11:21:42

The Eleven Labs site has a new tutorial posted showing you how to use the Symfony workflow component, a component designed to help make performing a sequence of operations simpler.

Since Symfony 3.2, a new useful component was born: the Workflow component.

It is indeed really convenient and can simplify greatly your developments when you have to manage status workflows in your application, that occurs a lot.

The tutorial starts by helping you get the Workflow component installed (via Composer) and an example configuration defining a flow for a pull request. They then show the command to generate the flow graph so you can ensure the workflow is correct. From there example code is provided to use the workflow and do things like:

  • checking if you can transition to a certain state
  • get the list of enabled transitions
  • event handling

Code examples and configuration options are also included for these points, helping you to make your workflow even more flexible.

tagged: tutorial symfony workflow component example

Link: http://blog.eleven-labs.com/en/symfony-workflow-component/

Yappa Blog:
Symfony Components in a Legacy PHP application
Jun 21, 2016 @ 12:50:13

On the Yappa Tech blog Joeri Verdeyen has written up a post covering the integration of modern Symfony components into a legacy application with a relatively simple container setup and configuration.

Symfony Components are a set of decoupled and reusable PHP libraries. They are becoming the standard foundation on which the best PHP applications are built. You can use any of these components in any of your applications independently from the Symfony Framework.

[...] The purpose of this post is to roughly describe how to implement some of the Symfony Components. I've created a set of gists to get started. You should already know how Symfony Components work in the Symfony Framework.

He starts with an example Composer configuration pulling in some of the more popular Symfony packages (like VarDumper and FormBuilder). He then includes the code to bootstrap the container instance and the services.yml he's come up with to bootstrap and integrate all of the components. The tutorial ends with examples of putting some of these components to use in resolving controllers, using the FormBuilder, using the command line and outputting errors with the VarDumper.

tagged: symfony component legacy application tutorial container example

Link: http://tech.yappa.be/symfony-components-in-a-legacy-php-application

Symfony Finland:
Using Symfony Finder and YAML components to transform Drupal 8 configurations to eZ
May 10, 2016 @ 10:58:31

On the Symfony Finland blog there's a tutorial posted showing how to translate Drupal 8 configurations into ones for eZ Platform using a bit of code inside a Symfony command.

Bolt CMS, Drupal 8 and eZ Platform all content management systems that use Symfony in one form or another. All of them use YAML to store configurations of content types and other system properties. This is great as it makes transferring between different formats quite straightforward.

This could be done by hand, but ideally configurations can be converted programatically. In this article we'll take a look at how to transfer content types from Drupal 8 to eZ Platform using a standard Symfony Command.

He starts with some background about the two configuration types (Drupal 8 and eZ Platform) before getting to the actual code to make the transformation. The code translates the Drupal 8 configurations over to the Kaliop Migrations format that can then be used in various environments. They include an example of the resulting configuration structure and, finally, the code to make the translation (allowing for multiple object types too).

tagged: symfony finder yaml component transform druapl8 configuration ezplatform

Link: https://www.symfony.fi/entry/using-symfony-finder-and-yaml-to-transform-drupal-8-configurations-to-ez-platform

Alejandro Celaya:
Improving ZendServiceManager workflow with annotations
Apr 11, 2016 @ 10:19:57

In a post to his site Alejandro Celaya shows you how to make life easier when using the ZendServiceManager with the help of annotations and a package he's developed to make it all work together.

Everyone who regularly visits my blog knows that I'm a complete fan of the ZendServiceManager component. It is always my choice to deal with dependency injection in any kind of project, more now that v3 has been released, which is faster and has a better public API.

The workflow while working with the ServiceManager is usually the same. You create a factory or abstract factory that creates a service and then you register that service into the ServiceManager itself. Of course you have to optimize your code, and you should try to reuse the same factories whenever possible, and try not to abuse of abstract factories and initializers.

He points out the main problem with using services like this in a larger application, namely that you can end up with a large amount of them, making them difficult to manage (and find problems with). He proposed solution uses this library to minimize the amount of code needed buy injecting dependencies into the service based on "inject" annotations. He includes an example of this functionality in action and includes a few things to keep in mind using the package (like the slower parsing of the annotations some limitations it currently has).

tagged: zend servicemanager component services workflow annotations inject tutorial library package

Link: http://blog.alejandrocelaya.com/2016/04/09/improving-zend-service-manager-workflow-with-annotations/

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - Web Example
Mar 30, 2016 @ 10:50:17

In a previous post Loïc Faugeron showed you how to take all of the components he'd talked about so far and make a simple API endpoint. In this latest post he takes the same functionality and makes a web-facing example instead.

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console. We've also seen how HttpKernel enabled reusable code with Bundles, and the different ways to organize our application tree directory.

Finally we've started to put all this knowledge in practice by creating a "fortune" project with an endpoint that allows us to submit new fortunes.

In this article, we're going to continue the "fortune" project by creating a page that lists all fortunes.

He goes through a similar process as before, but with a few changes to make it output a web page instead of API (JSON) results:

  • Create the Controller
  • Configure related routing
  • Create the logic to list all current fortunes
  • Putting the "wiring" in place to connect it to the database
  • Creating the view to output a simple page with the fortune list

It's that last step that's different, resulting in a simple (non-templated) page being output with HTML markup. He then refactors this to use Twig as the templating output layer, removing the output generation from the application logic.

tagged: ultimate developer guide symfony web example component combine tutorial

Link: https://gnugat.github.io/2016/03/30/ultimate-symfony-web-example.html

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - API Example
Mar 25, 2016 @ 10:31:09

Loïc Faugeron has posted another article in his "Ultimate Developer Guide to Symfony" series today. In this new article he shares an API example making use of the knowledge gained from the other articles to create a simple project.

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console.

We've also seen how HttpKernel enabled reusable code with Bundles, and the different ways to organize our application tree directory. In this article, we're going to put all this knowledge in practice by creating a "fortune" project with an endpoint that allows us to submit new fortunes.

He starts by creating the project (via Composer's create-project command), sets up a basic routing configuration and installs PHPUnit for testing. He then shows the creation of the controller - test first - to handle the "fortune" endpoint requests. He then comes back in and adds in some logic around the submission including matching tests. This is then refactored further to use Doctrine to insert the contents into a database. Additional code is provided showing how to "wire it all together" and create the database structure. The entire post takes the TDD approach so tests for all submission functionality are included.

tagged: ultimate developer guide symfony api example component combine tutorial

Link: https://gnugat.github.io/2016/03/24/ultimate-symfony-api-example.html

Symfony Blog:
New in Symfony 3.0
Mar 16, 2016 @ 09:39:21

On the Symfony blog there's a new post briefly looking at Symfony 3 and what's different about it as compared to previous releases (and what's not).

Symfony 3.0.0 was released on November 2015 as planned by the Symfony 3 roadmap. As we do with any new Symfony version, we should publish a blog series explaining its new features.

However, Symfony 3.0 is a very special version which contains no new features comparing it with Symfony 2.8. Their only difference is that 3.0 removed any feature marked as deprecated in 2.8. That's why we won't publish any "New in Symfony 3.0" post. Instead, let's do a quick recap of the new Symfony 2.8 features which are also available on Symfony 3.0.

Among the items on their list are things like:

  • New components like Guard Authentication and LDAP
  • A MicroKernel component
  • Improvements for VarDumper, Console and the Security components

Each of the changes on their list include links to get more information about the component and the post wraps up with a quick "how-to" on upgrading to Symfony 3 from other releases.

tagged: symfony symfony3 update release component change deprecation

Link: http://symfony.com/blog/new-in-symfony-3-0

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - Bundle
Mar 09, 2016 @ 10:53:40

Loïc Faugeron is back again with another of his "Ultimate Developer Guide" tutorials in his series. In his latest he looks at the Bundle component and the functionality it introduces as it relates to some of the components already discussed (like HttpKernel).

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console. In this article, we're going to have a closer look at how HttpKernel enables reusable code.

He starts by comparing the HttpKernel and Kernel components, laying them out so that their use makes sense later. From there he then gets into the actual Bundle component. He introduces the component, provides a code example showing its interface and talks about situations where bundles could be useful. To help make it a bit more "real world" he then shows how to create a "NanoFrameworkBundle" complete with Extension, Compiler, configuration and bundle definition examples.

tagged: ultimate developer guide symfony component bundle tutorial

Link: https://gnugat.github.io/2016/03/09/ultimate-symfony-bundle.html

Abdul Malik Ikhsan:
Start Using Middleware Approach with new zend-mvc
Mar 02, 2016 @ 12:54:37

Abdul Malik Ikhsan has a post to his site showing how you can integrate the concept of middleware in to the Zend MVC Component of the Zend Framework. Middleware has come into its own with the acceptance of of the PSR-7 standard and several frameworks adopting its structure for request/response handling.

zend-mvc 2.7.0 is coming, beside of the forward compatibility with V3 components, there is new middleware listener that allow us to do Dispatching PSR-7 middleware. The middleware can be an invokable class with __invoke() method.

He shows how, starting with a new project, to create the middleware class (in this case HomeAction) and the __invoke function. He then adds in the "home" route to the module configuration and points it at this HomeAction class. He registers it in the service manager as an InvokableFactory and it magically works. From there he refactors to allow the middleware to work with the ViewModel and change things like templates and variable values.

tagged: middlware zendframework zendmvc component psr7 tutorial invoke

Link: https://samsonasik.wordpress.com/2016/03/01/start-using-middleware-approach-with-new-zend-mvc/

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - Console
Mar 02, 2016 @ 09:34:21

Loïc Faugeron is back again with another in his "Ultimate Developer Guide" series each focusing on an individual component of the Symfony framework. In this new article he focuses on a very widely used component - the Console component.

In this guide we explore the standalone libraries (also known as "Components") provided by Symfony to help us build applications.

We've already seen: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML [and] Dependency Injection. We're now about to check the last one: Console.

He starts with the definition of an Application class and gives an example of using it to make a simple command line script. He talks about some of the built-in features and how to create Command classes that hold the actual functionality in your command-line tool. He finishes up the post by talking about the input, output and styling functionality also included with the component and how they can be used.

tagged: ultimate developer guide symfony component console tutorial

Link: https://gnugat.github.io/2016/03/02/ultimate-symfony-console.html