New in Symfony 3.3: Deprecated the ClassLoader component
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
The ClassLoader component was released on April 2012, when Composer was just a few months old and developing PHP applications was pretty different than today. Class autoloading is the mechanism used by PHP to load the classes referenced by your code and which haven't been required or included yet.
Symfony provides three autoloaders via the ClassLoader component: two of them load classes that follow PSR-0 and PSR-4 standards and the other one uses a static map of classes and files. In addition, Symfony provides special wrappers for those loaders to add caching and debugging features.
Although this component was useful to improve the application performance when using PHP 5, in the new PHP 7 era this is no longer true. That's why we've decided to deprecate the entire ClassLoader component.
If you use PHP 7, you can already test this change in your Symfony applications
by removing the following line in your front controllers (both
1 2 3 4 5 6 7 8 9 10 11
// app_dev.php // ... $kernel = new AppKernel('dev', true); // $kernel->loadClassCache(); <-- comment/remove this line // ... // app.php // ... $kernel = new AppKernel('prod', false); // $kernel->loadClassCache(); <-- comment/remove this line // ...
You shouldn't notice any performance impact in your application, as long as you use PHP 7 and the class loader provided by Composer. Finally, you should read the class loading optimization article recently published by Composer to know more about the options that will make your application faster.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.