Not optimized Composer on the production environment

Edit on GitHub

All pages are slow on the production environment.


The possible cause can be an unoptimized Composer for the production environment.

Here is an example of a profile from Blackfire:


As can be seen, there are many file_exists checks and findFilewithExtension that should be optimized.


Optimize the Composer autoloader. Follow the general performance guidelines and Composer guidelines.

For example, you can run the dump-autoload command with -o or --optimize.

After running the command defined in the guidelines, the profile can look like this:


As you can see, the two most time-consuming points are gone.

The comparison view looks like this:


We have optimized 40% of all time on the same action and reduced the number of file_exists checks and findFilewithExtension.

Some other possible optimizations include, for example, running the dump-autoload command with -a / --classmap-authoritative.

This is what profiling looks like after running this command:


To identify what exactly got updated, check the comparison view:


Now, way more actions got removed from the profiling result. The time is optimized by 87% from the initial report.

However, to avoid any potential issues with the autoloader optimization, check trades-offs on the official autoloader website.