How to Run Symfony 2 on PHP 7

php 7

For this follow-up article,I wrote a script that compiles PHP7 from source. This script was tested on Debian 8. It compiles PHP7 with all options Debian (and Dotdeb) usually do. You probably don’t use many of these options, but now you can easily strip down your configure string and re-run the shell script. It activates opcache, has the MySQL extensions and compiles PHP CLI and PHP-FPM.

Run Symfony 2 on PHP 7


You can extend the box to Nginx, MySQL, composer and Symfony2. Or you can do it manually and choose your favorite webserver, database server and PHP framework.


Installing Nginx, MySQL, composer and Symfony2

Configure your Nginx in a way that it points to the symfony installation by default in /etc/nginx/sites-enabled/default and restart nginx:
Now, browse to your Vagrant box’s IP (eg: if you used my git repository) and you will see the following in the Symfony debug toolbar:




I ran boom against the installation to get some differences in speed between different PHP versions. It’s just a simple metric on a vanilla installation to give you an idea, always run your own benchmarks to make decisions about your own projects. I compiled 5.3, 5.4, 5.5, 5.6 in the same way as PHP 7. Versions 5.3 and 5.4 use APC, the other ones use opcache.

This chart shows the number of requests per second that were performed (more is better). You can see that PHP 7 can do a lot more in comparison with the other versions. Response times drop from 0.2269 to 0.0865 seconds in the production environment.


I added an event listener on kernel.response to capture the memory usage:

This chart shows the peak memory usage and memory usage in dev and prod environments. It is interesting to see that the peak memory usage is actually higher with PHP 7, but overall the memory usage drops from 4,54 MB to 2,10 MB.

Leave a Reply