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

SitePoint PHP Blog:
Symfony Flex: Paving the Path to a Faster, Better Symfony
Oct 19, 2017 @ 13:16:52

On the SitePoint PHP Blog, there's a tutorial posted from editor Bruno Skvorc giving an introduction to Symfony Flex and how it is "paving the way" to a more performant future for Symfony.

Symfony Flex is a modern replacement for the Symfony Installer and not the name of the next Symfony version.

Internally, Symfony Flex is a Composer plugin that modifies the behavior of the require and update commands. When installing or updating dependencies in a Flex-enabled application, Symfony can perform tasks before and after the execution of Composer tasks.

The new Symfony will be called just Symfony 4, and while this tutorial will deal only with the Flex tool, it will mention some Symfony 4 upgrades as well.

The tutorial starts with some of the basics about Flex including its current development status and what kinds of things have changed from previous Symfony setups. It then walks you through the creation of a new Flex application including the bootstrapping of the application and the setup and use of application bundles.

tagged: symfony flex symfonyflex introduction tutorial bundle bootstrap

Link: https://www.sitepoint.com/symfony-flex-paving-path-faster-better-symfony/

Symfony Finland:
PHP 7.1 vs 7.2 Benchmarks (with Docker and Symfony Flex)
Oct 17, 2017 @ 11:17:25

On the Symfony Finland site there's a new post sharing the results of some recent benchmarks of the differences between running the framework on PHP 7.1 and PHP 7.2:

PHP 7.2 will be launching soon, in fact, it has already reached Release Candidate status. I was exploring Symfony Flex with Docker setup and thought I would do a quick round of tests to compare the differences in PHP 7.1 and 7.2 (RC4) regarding performance with a few benchmarks.

[...] The benchmarked application is the Symfony Flex port of the hybrid application I did back in January. The project now has the required configuration to run it with Docker, and you can find the full source on GitHub.

The post then shares some of the results and conclusions of the test runs, showing the differences between the two versions. In one set of tests, they're calling the front page controller with Twig rendering and in the other a backend controller without the display rendering. PHP 7.2 ends up performing slightly better than PHP 7.1 overall but not by very much in most cases. The more dramatic change is on the backend, though, with a good jump in performance for a Symfony Flex application.

tagged: symfony flex application benchmark php71 php72 compare results graph

Link: https://symfony.fi/entry/php-7-1-vs-7-2-benchmarks-with-docker-and-symfony-flex

Asmir Mustafic:
How do I deploy my Symfony API - Part 4 - Deploy
Oct 11, 2017 @ 10:23:12

Asmir Mustafic has posted the next part of his series covering the deployment of Symfony applications. In this latest article (part four) he focuses on some of the final steps of the deployment process.

This is the forth post from a series of posts that will describe the whole deploy process from development to production. The first article is available here, the second here and the third here.

After covering the steps 1-3 and having prepared our infrastructure, we can see how to deploy our application to production. Almost the same approach can be used to deploy not only to production but also to test environments.

He starts with the workflow for the deployment process, creating a flow where the "git push" should trigger other actions based on the branch pushed. Then CircleCI will fire off a series of jobs to handle environment setup tasks, connecting to a VPN and deploying the code. This includes a bit of preparation, credential handling and the Docker setup and push. Each step along the way also includes all of the YAML configurations you might need to replicate the deployment.

tagged: symfony api deployment part4 series docker configuration example

Link: https://www.goetas.com/blog/how-do-i-deploy-my-symfony-api-part-4-deploy/

Asmir Mustafic:
How do I deploy my Symfony API - Part 3 - Infrastructure
Oct 05, 2017 @ 09:29:06

Asmir Mustafic has posted the third part of his series covering the deployment of Symfony API applications. In this latest part (part three) of the series, he focuses on the infrastructure piece.

This is the third post from a series of posts that will describe the whole deploy process from development to production. The first article is available here and the second here.

In the previous two articles, I've covered the steps 1-3 from the schema here below. Before being able to discuss the steps 4-5 we will need to see how to configure the instances properly to be able to deploy our application to a docker-swarm cluster with rolling updates.

He starts off by describing the pieces that will make up the infrastructure: a PostgreSQL database, Docker swarm for machine/VM management and AWS instances to run the containers on. He then starts in on the instance type and setup you'll need to get the system up and running including manager and worker nodes. The post wraps up with a list of things he sees as improvements for the future such as using a custom AMI, use of elastic load balancers and handling node failure a bit better.

tagged: symfony api deployment tutorial infrastructure part3 series

Link: https://www.goetas.com/blog/how-do-i-deploy-my-symfony-api-part-3-infrastructure/

Ibrahim Gunduz:
Sending Logs From Symfony Applications To GrayLog Through RabbitMQ
Sep 29, 2017 @ 11:17:10

On his Medium.com site ?brahim Gündüz has posted a tutorial showing you how to send logs from Symfony to Graylog via RabbitMQ, making use of backend queues to handle moving log information into the Graylog instance.

Message Queues are indispensable tools of the systems which is under high load. You can split your systems to small pieces and provide communication between each other through message queue services.

If your system happens by many pieces it means you have so many log entries which is coming from multiple application instances in same time. So you should scale your logging system like how you scaled your application also. Otherwise, your application may go down because of your logging system might be bottleneck.

You can use message queue systems to avoid this trouble.

He starts by helping you install the Composer dependencies required for the RabbitMQ interface and defining the configuration in Symfony to make the connection to the queue. With this in place he moves over to the RabbitMQ side and sets up the queue and exchange to handle the incoming log information. He then creates a LoggingTestCommand command to test out sending the logs to the queue and shows the setup of Graylog to read from that queue and pull in the information automatically.

tagged: symfony tutorial rabbitmq graylog log integration

Link: https://medium.com/@ibrahimgunduz34/sending-logs-from-symfony-applications-to-graylog-through-rabbitmq-4735aebfce4b

Symfony Blog:
Symfony 3.4 and 4.0 are about to enter into their "feature freeze" period
Sep 28, 2017 @ 11:28:42

On the Symfony blog there's a new post talking about the upcoming feature freeze for Symfony 3.4 and 4.0.

Symfony project follows a time-based development process where two new minor versions are released each year and a major version is released every two years.

This year, Symfony 3.4 and Symfony 4.0 will be both released at the end of November 2017. The only difference between both versions is that 3.4 includes all features deprecated in 3.x branches and 4.0 removes them.

Two months before their final releases, Symfony versions enter into a "feature freeze" period. During this time, we can't add new features and we solely focus on polishing and stabilizing the new features (and even reverting them if they don't work properly).

In other words, this week is our last chance to add new features to Symfony 3.4 and 4.0.

The post lists out a few ways that you can help out including reviewing pull requests and issues to see if there's anything that might be missing from these releases and might need to be integrated pre-freeze.

tagged: symfony framework featurefreeze v34 v40 project

Link: http://symfony.com/blog/symfony-3-4-and-4-0-are-about-to-enter-into-their-feature-freeze-period

Asmir Mustafic:
How to add custom error codes to your Symfony API responses
Sep 22, 2017 @ 11:10:01

Asmir Mustafic has posted a guide on his site showing how to create custom error codes in the API responses from your Symfony-based application.

When writing APIs, a proper error handling is fundamental. HTTP status codes are a great start, but often when we deal with user inputs is not enough. If out model has complex validation rules, understanding the reason behind an 400 Bad Request error can be not trivial.

Fortunately when for symfony developers there are many libraries to deal with it. Symfony Validator, <a href="https://github.com/symfony/form>Symfony Form, <a href="https://github.com/FriendsOfSymfony/FOSRestBundle>FOS REST Bundle and JMS Serializer combined allows you to have nice error messages to be shown to your users.

He walks you through the code required to create the default error handling with an "author" example. This includes the creation of the entity as well as the form and controller to handle the request/response. He then refactors this away from the default to create the custom error handler with handlers for the message and code to be returned. The post ends with the configuration changes to register it with the application and what the result ends up looking like.

tagged: symfony tutorial custom error code api example

Link: http://www.goetas.com/blog/how-to-add-custom-error-codes-to-your-symfony-api-responses/

Dragos Holban:
How to Setup Docker for Your Symfony Project
Sep 18, 2017 @ 11:48:31

In a tutorial posted to his Medium.com site Dragos Holban continues his series walking you through Symfony for PHP applications. In this latest part of the series he shows you how to use Docker to set up an environment for a Symfony-based application.

As you probably know, I am a big Symfony fan :) In the last few years I used Vagrant to set up my Symfony development environment more or less as described here. But we now have Docker and it’s time to move forward with a new setup. Docker containers are generally more lightweight than Vagrant virtual machines, so starting and stopping them is extremely fast. They also take a lot less disk space.

He starts by sharing an example Dockerfile and docker-compose.yml to help set up and configure the environment to be ready for use. The configuration sets up Apache, PHP 7, MySQL, git, Composer and several PHP extensions. It then installs a fresh instance of Symfony and runs a bash file to finish the setup. He shares the contents of this file and the VirtualHost configuration for the web server. Finally he shows how to run the setup via the Docker command line tool and what you can expect to see when things are running smoothly.

tagged: docker symfony setup configure dockerfile compose tutorial series

Link: https://medium.com/@dragosholban/how-to-setup-docker-for-your-symfony-project-ff9b1bf44e68

SitePoint PHP Blog:
Symfony Console Beyond the Basics – Helpers and Other Tools
Sep 14, 2017 @ 11:12:42

The SitePoint PHP Blog has a new tutorial posted from author Claudio Ribeiro that takes you beyond the basics with the Symfony Console component, showing you how to use some of the helpers and other tools included in its functionality.

It’s undeniable how useful console commands can be when developing software. Not too long ago we re-introduced the Symfony Console component.

This component allows us to create structured and testable CLI commands. We created some simple commands and tested them; but when our commands become bigger and more complex, we need a different set of tools.

This is what we are going to look at today: advanced Symfony console tools.

He then walks you through the installation of the component via Composer and the initial creation of a "FizzBuzz" console command class (and other related classes). He then shows how to use several of the helpers:

  • the "question" helper to ask for user input
  • the "table" helper for outputting structured data
  • the "progress bar" helper to visually output progress of a task

There's also examples included showing how to call a command from inside a command and changing up color and style of the output.

tagged: tutorial symfony console advanced helpers command

Link: https://www.sitepoint.com/symfony-console-beyond-the-basics-helpers-and-other-tools/

Symfony Blog:
The Symfony Unicorn: 1 Billion Downloads
Sep 12, 2017 @ 12:55:32

On the Symfony blog they talk about a major milestone the framework has reached: one billion downloads of the components that make up the Symfony framework.

A Symfony unicorn!!? It's real! On September 5th, the Symfony Components crossed a huge landmark: the 1 billionth download! This happened less than one year after the last milestone: 500 million downloads. That's right: the PHP community downloaded the Symfony components more than 500 million times in just one year. That's well over 1 million downloads every day!

There are so many people that have made this possible, and we would like to thank all of you who have supported Symfony: developers, contributors, companies, evangelists and - of course - users! There are now over 80 Symfony packages and 1,500 people have contributed code to these. None of this is possible without your help. Congrats!

The post then talks about the current state of the components (including their download numbers), their backwards compatibility promise and how it relates to the upcoming Symfony 4 release.

tagged: symfony component billion download achievement framework

Link: http://symfony.com/blog/the-symfony-unicorn-1-billion-downloads