Symfony: performance

Symfony is fast, right out of the box. Of course, if you really need speed, there are many ways that you can make Symfony even faster.

Use Composer’s Class Map Functionality
By default, the Symfony Standard Edition uses Composer’s autoloader in the autoload.php file. This is quite slow though as the loader iterates over all configured namespaces to find a particular file, making file_exists calls until it finally finds the file it’s looking for.

To speed this up, the simplest solution is to tell Composer to build a class map (i.e. a big array of the locations of all the classes). This can be done from the command line, and might become part of your deploy process. Internally, this builds the big class map array in vendor/composer/autoload_classmap.php:

$ composer dump-autoload --optimize