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

Marc Morera:
Bye Bye Symfony
Sep 04, 2014 @ 17:41:00

In his most recent post Marc Morera says bye bye to Symfony and "hello to PHP". Confused? His point is that using the Symfony components as a whole in the framework isn't the only option anymore. You can use them just as effectively as pieces of a larger PHP project, puling them in as needed.

The reason of this post is just to tell you, with a simple example, how to say Bye Bye, Symfony! and say Hi PHP!. This really means uncouple from Symfony Components and still use them as the default implementation, while we can securely remove, from the composer require block, our Symfony dependencies.

He starts off with a simple example showing how to use Symfony's "UrlGeneratorInterface" to create a URL output class that can be injected to use in the route handling of the application. He then moves on to a more real-life example (a metaphor) using a USB connection and the adapters/cables that could be involved to connect various devices. He then shifts back over to the world of code and describes a specification interface that can be used with the URL generation and remove the Symfony dependency from it. On top of this he builds an adapter object that brings the Symfony component back into the picture and abstracts it out a level to make for more flexibility and testability in the long run.

We win maximum implementation flexibility and minimum coupling. Would be wise to say that a PHP project should tend to this thought, but once again, it depends on many factors. [...] Using ports and adapters is really a great tool for those who want to uncouple from implementations and a great pattern if you develop open source. Open source should satisfy as people as possible, so remember, specify and then implement.
tagged: symfony component abstract tutorial interface specification

Link: http://mmoreram.com/blog/2014/09/01/bye-bye-symfony/


Trending Topics: