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

Eleven Labs Blog:
RabbitMQ: Publish, Consume, and Retry Messages
Feb 03, 2017 @ 12:53:06

On the Eleven Labs blog they're posted a tutorial showing you how to integrate RabbitMQ functionality into your Symfony-based application making use of a few handy tools that do some of the heavy lifting for you and how messages are handled (and what to do when they error).

RabbitMQ is a message broker, allowing to process things asynchronously. There’s already an article written about it, if you’re not familiar with RabbitMQ.

What I’d like to talk to you about is the lifecycle of a message, with error handling. Everything in a few lines of code. Therefore, we’re going to configure a RabbitMQ virtual host, publish a message, consume it and retry publication if any error occurs.

They use the RabbitMQ admin toolkit and Swarrot packages to get the job done. First up is the configuration of the tools, creating a default_vhost.yml file defining a queue and setting up the exchanges and parameters for the default route ("/"). They show an example of what the RabbitMQ UI looks like with this new exchange up and working and how to get more information about this "default" queue. Next up is the consumption and publication of messages. They include an example app/config/config.yml file that defines some settings the Swarrot library (via the SwarrotBundle) needs to understand the connections, consumers and type of provider to use. Finally he shows the configuration so it all knows how to publish messages and a quick example of PHP code that sends a simple string message to be handled by the RabbitMQ workers. The post ends with a bit more configuration and some examples of how to handle errors in this Swarrot/RabbitMQ Admin Toolkit setup and making use of some middleware to help with message retries and number of attempts.

tagged: tutorial rabbitmq symfony bundle swarrot configuration publish consume retry error

Link: http://blog.eleven-labs.com/en/rabbitmq-publish-consume-retry-messages/

Symfony Finland:
Sharing state in a Symfony hybrid with Twig, React and other JavaScript apps
Jan 26, 2017 @ 11:14:12

The Symfony Finland site has posted a new tutorial showing you how you can share state in a Symfony application between Twig, React and other Javascript-based applications.

Front end development has certainly grown up in the last few years. UI logic is increasingly being moved to the client side, but the traditional server-rendered views aren't going anywhere soon. And they shouldn't.

The two methods will live alongside each other and you'll have to work with two worlds. Let's explore an idea how to make this pleasant to work with, by sharing state between Twig templates and JavaScript.

The post starts with some background on a case where this kind of sharing was a requirement and, while the initial version was scrapped, a prototype application was born. He details what this prototype showcases (which JS libraries) and links to the Javascript involved over on GitHub. They then get into the code examples showing the creation of an AppState object that handles the serializing of the state information and store the result in the database via a Doctrine connection. This value is then output to the pages that require it, making it available to the frontend application (Vue.js, React or plain Javascript).

tagged: tutorial symfony shared state backend frontend javascript twig react vuejs

Link: https://www.symfony.fi/entry/sharing-state-in-a-symfony-hybrid-app-with-twig-react-etc

Matthias Noback:
Introducing the SymfonyConsoleForm package
Jan 20, 2017 @ 11:12:51

In a new post to his site Matthias Noback introduces you to a package that can help you in your Symfony-based console application, combining the Form and Console components, to make it easier to create "forms" on the CLI.

About 2 years ago I created a package that combines the power of two famous Symfony components: the Form component and the Console component. In short: this package allows you to interactively fill in a form by typing in the answers at the CLI. When I started working on it, this seemed like a pretty far-fetched idea. However, it made a lot of sense to me in terms of a the package in use, building a "form" that just asks the user to input a name. An image of the result is included as well. He ends the post with some of his other general findings during the process of creating the package and suggests a few common use cases including installation wizards that can be used in both the CLI and web interfaces.

tagged: symfonyconsoleform package tutorial console form component symfony

Link: https://php-and-symfony.matthiasnoback.nl/2017/01/introducing-symfony-console-form/

Symfony Blog:
Symfony 2016 Year in Review
Jan 12, 2017 @ 11:29:33

The Symfony blog has posted their wrap up of the activities around the project and its ecosystem in 2016. They cover releases made, events/conferences and updates on both components and documentation changes.

The beginning of a new year is the best moment to review all that happened during the previous year. These are some of the highlights of the 2016 year for the Symfony Project.

[...] 2016 was the best year in Symfony Project's history. 2017 will be even better and it will bring us new projects such as "Symfony Flex" (a new way to manage Symfony applications unveiled during the SymfonyCon Berlin 2016 conference), 1 billion downloads for Symfony Components (if the download rate keeps growing) and the return of the Symfony conferences to the United States (San Francisco, October 19-20).

Each of the sections talks about the changes over the last year and links to other resources, profiles and documentation about the update. This also includes the top contributors to the framework, new contributors and top documentation contributors.

tagged: symfony framework yearinreview 2016

Link: http://symfony.com/blog/symfony-2016-year-in-review

Stefan Koopmanschap:
Best practices on bundles in Symfony
Dec 29, 2016 @ 10:53:39

Stefan Koopmanschap has a new post to his site sharing some best practices with bundles in Symfony including structure of both the bundle and the application it lives in.

On one of my recent commutes I started listening to the Sound of Symfony podcast. As I had just discovered that one, I decided to listen to their most recent episode, which is on best practices for bundles. I quite disagreed with what was being said in the podcast. I started voicing my disagreement on Twitter but quickly decided that 140 characters is not enough to really explain my disagreement. So here's a blogpost.

He starts by talking about some of the current "best practices" documentation (like this book) and the parts of it he disagrees with. He talks about the use of the AppBundle, the general structure of a Symfony project and the use of bundles to provide better structure to your own code. He covers the placement of you code (your "domain") and the integration of the idea of bounded contexts. He finishes the post with some of his own experience with various frameworks and both good and bad project structures - and how sometimes the default framework structure isn't really what's needed.

tagged: symfony bestpractice bundles structure application opinion soundofsymfony

Link: http://leftontheweb.com/blog/2016/12/29/best-practices-on-bundles-symfony/

Amine Matmati:
Symfony: the Myth of the Bloated Framework
Dec 20, 2016 @ 12:25:50

Amine Matmati has written up a post with a few quick points refuting the "bloated framwork" myth as it relates to the Symfony framework.

At work, we’re trying to choose which PHP framework to use for our next project. As we’re breaking up our monolithic app into services, only micro frameworks were considered by the team. This choice was made to avoid the pain points we’ve encountered using our current full stack framework.

Not all full stack frameworks are created equal, however. Having worked with Symfony before, I proposed it as an option. As expected, I’ve had some pushback from my fellow coworkers. The main reason being that Symfony is bloated and overkill for our needs.

He then goes on to talk about how, despite many Symfony components being used individually by other projects, the overall framework still has the reputation for bloat. He goes through some of the main points usually mentioned by the opponents:

  • Doctrine is complex/bad/slow
  • Symfony is too verbose
  • Symfony uses too much configuration

He does agree with some of the points made but usually not in the general way they've been stated. For example, while he does agree that Symfony is verbose he also points out that this verbosity provides more control to the developer as to exactly how things hook together.

tagged: symfony myth bloated framework opinion doctrine configuration verbose

Link: http://matmati.net/symfony-myth-bloated-framework/

Freek Van der Herten:
Symfony and Laravel will require PHP 7 soon
Dec 19, 2016 @ 10:36:19

As Freek Van der Herten mentions in this recent post to his site, it was announced by both Fabien Potencier (Symfony) and Taylor Otwell (Laravel) that the upcoming versions of the frameworks - Symfony 4 and Laravel 5.5 - will require PHP 7 by default.

According to Fabien Potencier, lead of the Symfony project, the next major version of Symfony, to be released at then end of 2017, will require PHP 7. But Laravel will drop PHP 5 support even sooner. Taylor Otwell, the creator of Laravel, announced that Laravel 5.5, to be released in June 2017, will leave PHP 5 behind.

Freek talks some about the improvements that come with PHP 7 and which he thinks will show up in the different frameworks' codebase. He sees this as "a message" to the PHP community as a whole that the migration to PHP 7 should happen sooner rather than later (and some of his own work to help reinforce this).

tagged: symfony laravel php7 requirement framework package

Link: https://murze.be/2016/12/laravel-5-5-will-require-php-7-0/

Symfony Blog:
How to solve PHPUnit issues in Symfony 3.2 applications
Dec 14, 2016 @ 11:53:49

On the Symfony blog there's a quick post sharing helpful advice about fixing PHPUnit tests in Symfony 3.2 applications, mostly around an issue involving the use of the "phar" distribution and a class constant error.

If your application uses Symfony 3.2 and you execute PHPUnit via its PHAR file, you'll end up with the following error message [about the "PARSE_CONSTANT" constant]. In Symfony 3.2 applications you can't use the PHAR file of PHPUnit and you must use instead the PHPUnit Bridge.

They provide the commands to get this bridge installed (via Composer) and how to execute the PHPUnit tests post-install (using the "simple-phpunit" command instead). They explain why this process needs to be followed to run the tests correctly and how the PHPUnit-bridge package helps to resolve the situation.

tagged: phpunit issue symfony v32 bridge constant error

Link: http://symfony.com/blog/how-to-solve-phpunit-issues-in-symfony-3-2-applications

Symfony Finland:
PHP 7.1 vs. 7.0 performance benchmarks with Symfony
Dec 12, 2016 @ 10:04:09

On the Symfony Finland site they've post together a post sharing some benchmark results of Symfony on PHP 7.0 versus 7.1, the most recent major release of the PHP language with some improvements of its own.

PHP 7.1 was launched on December 1st 2016. This was the first minor release after the release of 7.0 a year ago. PHP 7.0 was a revolutionary product, especially when it comes to memory usage and performance. PHP 7.1 is a more modest upgrade that brings new features and improved performance. But how much has performance improved from a year back?

The benchmarking uses the eZ Platform demo running a full CMS similar to the previous benchmarking done in 2015. The checks were run using:

  • a "clean" environment (no caching, PHP-FPM just restarted and no APC cache)
  • standard requests running in development mode
  • more requests but this time in production mode

The post shares the results with a few graphs showing them in terms of response time for both sequential and concurrent page requests.

tagged: php70 php71 benchmark symfony ezplatform cms results

Link: https://www.symfony.fi/entry/php-7-1-vs-7-0-benchmarks-symfony

Stovepipe Systems:
What are Bundles in Symfony?
Dec 06, 2016 @ 10:22:56

On the Stovepipe Systems Dev blog today Iltar van der Berg has shared a post about bundles, one of the key concepts in the Symfony ecosystem - what they are and some of the common features they all share.

People often refer to bundles as modules or re-usable code for Symfony applications. When a developer has experience with Symfony1 or another framework with the module concept, it might seem logical that this is what a bundle represents in Symfony.

So what is a bundle? When do you need one and what can it do? What's the difference between an AppBundle and a vendor Bundle?

He starts with the release of Symfony 2, including bundle support, and how common practices created hard dependencies between bundles. This created issues in the applications and reusability of the bundles (their whole purpose) so a solution was created: the AppBundle. This bundle shifted the emphasis away from the file structure of the bundles and more towards the domain they occupied, handling some "magic" references automatically for you.

As mentioned, the bundle provides an extension point. Other bundles for example, can hook in on your bundle because it contains some logic to expose information such as the directory of the bundle.

[...] The main purpose of a bundle however, is to provide an extension point for the Dependency Injection Container. When talking about this extension point, it revolves around adding, changing or removing service definitions.

tagged: symfony bundle introduction appbundle vendor

Link: https://stovepipe.systems/post/what-are-bundles-in-symfony