PHP preloading and Symfony
PHP 7.4 added support for preloading. To make a long story short, it gives you extra performance for free. Symfony 4.4 made it easy to benefit from this feature in your projects.
You might wonder how easy it is to benefit from it? It is actually surprisingly
easy. When a new Symfony project is created, Flex will create a config/preload.php file to help PHP preload some PHP files. To enable preloading, you must tell PHP where this
file is stored in its
php.ini configuration file:
# from the symfony/framework-bundle recipe opcache.preload=/app/config/preload.php
I’ve done it on all the websites I manage for my Open-Source projects. Here is the boost on the twig.symfony.com homepage:
On more complex websites, with database accesses, the percentage is going to be less dramatic, but still interesting.
php.ini template now contains this configuration, so uncomment
the right line depending on your Symfony version and enjoy a nice and free
PHP preloading and Symfony symfony.com/index.php/blog/php-preloading-and-symfonyTweet this
Become a certified developer! Exams are online and available in all countries.Register Now
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.