What's the purpose of the Symfony2 bootstrap.php.cache file? What's the purpose of the Symfony2 bootstrap.php.cache file? symfony symfony

What's the purpose of the Symfony2 bootstrap.php.cache file?


To ensure optimal flexibility and code reuse, Symfony2 applications leverage a variety of classes and 3rd party components. But loading all of these classes from separate files on each request can result in some overhead. To reduce this overhead, the Symfony2 Standard Edition provides a script to generate a so-called bootstrap file, consisting of multiple classes definitions in a single file. By including this file (which contains a copy of many of the core classes), Symfony no longer needs to include any of the source files containing those classes. This will reduce disc IO quite a bit.

Source: Use Bootstrap Files.


From the Symfony documentation:

To ensure optimal flexibility and code reuse, Symfony2 applications leverage a variety of classes and 3rd party components. But loading all of these classes from separate files on each request can result in some overhead. To reduce this overhead, the Symfony2 Standard Edition provides a script to generate a so-called bootstrap file, consisting of multiple classes definitions in a single file. By including this file (which contains a copy of many of the core classes), Symfony no longer needs to include any of the source files containing those classes. This will reduce disc IO quite a bit.

You can generate your bootstrap file like this:

php vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php


The bootstrap cache file can be an irritation during development because it changes the line numbers in stack traces. Fortunately it can be easily disabled in web/app_dev.php.