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

Fabien Potencier:
Symfony 4: Contributing Recipes
Apr 19, 2017 @ 10:23:34

Fabien Potencier has posted another in his series of tutorials looking at the next major release of the Symfony framework - Symfony v4. In this series he's covered some of the changes that will be coming in this release and what you can do to prepare. In this latest post he looks at the idea of "recipes" and how you can contribute them back to the project

Symfony Flex is not Open-Sourced yet, but I can already feel the excitement in the community. [...] You know, that "one more feature" that will make Symfony Flex the next killer application for the Symfony community.

People are worried about the opinionated recipe repository. Keep in mind that one of the main goals of Symfony Flex is to automate your day-to-day workflow for the happy path.

He reassures those reading the post that a package doesn't need a recipe to be installed and the "opinions" that the main repository uses around packages. He also talks about another recipe configuration option not mentioned previously: aliases. These allow for shortened versions of the Composer installation commands that are easier to remember than the full package name. He covers a bit about how it works in Flex and the process it follows behind the scenes when installing the package.

tagged: symfony4 symfony contribute recipe framework symfonyflex

Link: http://fabien.potencier.org/symfony4-contributing-recipes.html

Fabien Potencier:
Symfony 4: Monolith vs Micro
Apr 05, 2017 @ 09:43:14

Fabien Potencier is back with a new post on his site following up this article about application composition and Symfony 4. In his latest post he compares two approaches to applications: micro versus macro.

Monolith projects versus micro-applications; a never-ending debate. Both ways to develop applications are fine in my book. Symfony supports both. Even if the Symfony Standard Edition is probably more suitable for monolith projects as it depends on the symfony/symfony package.

[...] Silex took another approach where each individual components are required when needed. Does it make Silex simpler, more lightweight, or faster than Symfony? No. Nevertheless, Symfony 4 is going to be more similar to Silex in this regard.

He talks about changes upcoming in Symfony 4 including the move away from the "symfony/symfony" package system and in with a component/bundle driven system. He gets into a specific example around the "symfony-framework" bundle. He then comes back around to the idea of "composition" of applications, adding Symfony dependencies only when needed but still having them work together seamlessly. The post ends with a discussion that was had about going the "bundle-less application" route and, while Symfony 4 will recommend it, the bundle system will still function as expected.

tagged: symfony symfony4 bundle application micro macro framework

Link: http://fabien.potencier.org/symfony4-monolith-vs-micro.html

Fabien Potencier:
Symfony 4: Compose your Applications
Apr 03, 2017 @ 10:31:26

On his site Fabien Potencier has posted an article about the next major release of the Symfony framework - version 4 - and how it will allow for the "composition" of your applications rather than some of the current methods.

Symfony 3.0 was boring, a cleaned-up version of the Symfony 2.8 version. Symfony 4.0 will be different: Symfony 4.0 = Symfony 3.4 - deprecated features + a new way to develop applications

There is another way to think about a new major version though: Symfony 4.0 = Symfony 3.0 + all features added in 3.x - deprecated features + a new way to develop applications

He goes through some of his thinking process around some of these changes and the "day-to-day experience" of managing a Symfony application. Specifically he suggests that:

  • Installing a Bundle is too cumbersome
  • Removing a Bundle is even more cumbersome
  • The Symfony Standard Edition is not good enough
  • No Distribution Ecosystem

He ends the post with a look at what he sees as the ideal ecosystem for the framework and where Symfony Flex fits into the picture (example project here).

Symfony Flex is going to be the default way to manage Symfony 4 applications. But Symfony Flex will be available as an option to manage Symfony 3.3 and 3.4 applications as well! That said, we might need to break backward compatibility between now and the launch of Symfony 4. Consider Symfony Flex as alpha before Symfony 4.
tagged: symfony symfony4 compose application progress ecosystem

Link: http://fabien.potencier.org/symfony4-compose-applications.html

Robert Basic:
Loading fixtures for a Symfony app in Behat tests
Mar 23, 2017 @ 10:38:58

Robert Basic has a new post to his site with some advice for the Behat users out there testing their Symfony applications. He shows how to easily load up fixture data with the help of Doctrine.

Performing end to end testing of any application requires from us to have a set of reliable test data in the database.

If we write a Symfony application and use Behat to do the end to end testing, the we can use the Doctrine fixtures bundle to create the required fixture loaders and load them in our Behat scenarios when required.

He walks you through the installation of the Doctrine fixtures bundle (via Composer, naturally) and how to enable it via the Symfony kernel configuration. He then includes an example of the fixture loader class from the FOSUserBundle and how it works. Next up is the installation of the Behat Symfony 2 extension and a bit of extra code to make a new feature context for Behat containing a "loadDataFixtures" method to do the heavy lifting.

tagged: fixture symfony application behat load extension bundle tutorial

Link: https://robertbasic.com/blog/loading-fixtures-for-a-symfony-app-in-behat-tests/

Stefano Alletti:
Symfony and Monolog, how use Processor in your project: a practical example
Mar 17, 2017 @ 12:23:44

Stefano Alletti has written up a post to his site showing how to combine Symfony and Monolog along with a custom "processor" to modify the message and content being logged.

We often have to use different micro-services who write in many log files. Use utilities like Kibana is a good thing, but in order to take full advantage of its features we have to try to standardize and normalize the logs.

The company where I work having introduced Kibana recently, he asked me to implement a proper strategy to log all the micro-services.

He starts by outlining the fields that are required to be in the log output (a great place to start) before moving into the code to implement the logging. He briefly talks about Monolog itself and how to implement it in a Symfony application. The remainder of the post includes the code to implement the logger and how to add the custom processor to modify the extra data being included in the logged data. He also goes a step further and creates a custom formatter to modify the output in the message for the customer ID and product line values.

tagged: tutorial symfony monolog processor formatter integration

Link: https://stefanoalletti.wordpress.com/2017/03/09/symfony-and-monolog-how-use-processor-in-your-project/

Fabien Potencier:
The Symfony Trademark
Mar 15, 2017 @ 09:49:58

In a post to his own site Fabien Potencier attempts to clear up any confusion around the use of the Symfony trademark and how SensioLabs manages that trademark.

This blog post has been written after some concerns expressed on Twitter and Reddit about how SensioLabs manages the Symfony trademark. If you want to read the details about the Grafikart issue, scroll to the end [of the post]; reading the whole post is recommended though if you want to understand the whole story.

Fabien starts at the very beginning, talking about how he selected the name for the framework and how it evolved over the years. It was a few years in when he decided to register the trademark officially and the legal battle that came with it. He also talks about the trademark policies they worked up and other projects that have a similar setup. He then gets into some more specific examples where there could be conflicts with these rules.

Enforcing the trademark is a painful process and it costs a lot of money. But I'm convinced that doing so is my responsibility. Would it be fair to say no to people who follow the rules by asking for permission and let other companies do whatever they want? Not in my book.

The rest of the post is dedicated to one particular issue (involving Grafikart) and the issues that came up because of mishandling on the legal side and the changes being made to prevent the confusion in the future.

tagged: symfony trademark sensiolabs framework grafikart

Link: http://fabien.potencier.org/the-symfony-trademark.html

Codevate.com:
Driving user engagement by leveraging Disqus in Symfony-based web apps
Mar 06, 2017 @ 10:27:22

The Codevate blog has a tutorial posted by Chris Lush showing how to "drive user engagement" with Disquis in a Symfony-based application. He basically shows how to use commenting, with the help of Disquis, to encourage user participation with your content without having to build your own.

Engaging your audience is an ever-increasing concern when publishing content, since having a community that visitors can witness and interact with can help drive repeat traffic to your website. One such approach would be to let users write comments about your content, creating discussion that others can engage with. The temptation to implement your own comment system is strong since at a surface level it's a simple problem to solve, but to build a robust solution that can deal with moderation requirements such as banning & blocking users, editing comments, or just exploring related threads within a forum can easily turn your "users can write comments" requirement into another project in its own right.

Disqus to the rescue.

He starts by showing the benefits that using Disquis can provide to your site and outlines the steps required to get it up on your site. He then walks you through the process, step-by-step, of registering with the Disquis service, adding the code to your site and even integrating single sign-on with your own backend system.

tagged: user engagement disquis tutorial symfony application

Link: https://www.codevate.com/blog/15-driving-user-engagement-by-leveraging-disqus-in-symfony-based-web-apps

SitePoint PHP Blog:
The State of PHP MVC Frameworks in 2017
Mar 03, 2017 @ 09:49:40

The SitePoint PHP blog has a new post sharing the current state of PHP MVC frameworks in 2017. The article doesn't focus on any particular list of frameworks (though the more popular ones are used in the examples) and instead focus on the overall trends they've seen in frameworks and their use.

A simple question prompted me to sit down and write this follow up to my article from about a year ago: "Any thoughts about where things are today?"

He suggests that, while several of the major frameworks are still in active development and are seeing new features in recent versions, the front-runners are probably Laravel and Symfony. He includes trend numbers to back this up (popularity, basically) but also briefly touches on others: CakePHP, CodeIgniter and Zend Framework 2. He then breaks it down into two groups: Symfony/Laravel and "the rest". The post wraps up with a look at the rise of microservices, the "destruction of the monolith" and a more recent emphasis on scalability over just features.

tagged: state mvc framework 2017 opinion laravel symfony trend popularity

Link: https://www.sitepoint.com/the-state-of-php-mvc-frameworks-in-2017/

Toptal.com:
PHP Frameworks: Choosing Between Symfony and Laravel
Mar 02, 2017 @ 11:26:17

On the TopTal.com blog Karin Sakhibgareev shares some of his thoughts around picking the right framework for your project. More specifically he focuses on the selection between two popular options: Symfony or Laravel.

Today, when starting a new project, one of the key decisions is to pick the right framework. It’s become hard to imagine building a complex web application from scratch nowadays without one.

Many popular languages for web development have their “default” framework, such as Ruby on Rails for Ruby, or Django for Python. However, PHP has no such single default and has multiple popular options to choose from.

[...] In this article, I am going to compare these two frameworks and show you how to implement simple, everyday features with each. This way, you can compare the code of real-life examples side by side.

He starts with a brief history of each project (Symfony and Laravel) and quick guides to getting them installed. He then configures them with a few basic options (database connection, security details, etc) and compares the setup processes against each other. The reminder of the post follows the same pattern covering:

  • routing setup and configuration
  • templating (Blade vs Twig)
  • dependency injection
  • database usage via ORMs
  • event dispatching/middleware

The post ends with a sort of "real world" application of each framework, showing what it would take to create a simple REST API. He finishes with his thoughts about the "winner" of the comparison...but suggests that it's more about the right tool for the right job than one framework that does it all.

tagged: toptal framework symfony laravel tutorial comparison

Link: https://www.toptal.com/php/choosing-between-symfony-and-laravel-frameworks

Frank de Jonge:
Battle Log: Symfony Routing performance considerations.
Feb 28, 2017 @ 10:55:24

In a new post to his site Frank de Jonge shares his "battle log" when looking into routing performance considerations in Symfony after a "deep dive" into the component's code.

Last week I took a deep dive into Symfony's Routing Component. A project I worked on suffered from a huge performance penalty caused by a routing mistake. This lead me on the path to discovering some interesting performance considerations. Some common practices align nicely with Symfony's optimisations, let's look into those.

He starts off by describing the process he took to start the investigation and what prompted him to investigate the performance issue. He talks about his use of profiling to locate the bottleneck and track down the root cause. He answers the five "why's" about the issue and uses that to guide an approach. Ultimately he located the source of the issue - YAML parsing that shouldn't have been needed - and what the component does to make it more performant in non-development environments. He ends the post with a list of four performance considerations as you're going through your own development to get the most out of the component.

tagged: symfony performance routing considerations deepdive

Link: https://blog.frankdejonge.nl/symfony-routing-performance-considerations/