Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages showcasing Symfony with Docker, APIs, queues & async tasks, Webpack, SPAs, etc.


You are browsing the documentation for Symfony 3.4 which is not maintained anymore.

Consider upgrading your projects to Symfony 5.2.

The ClassLoader Component

3.4 version

The ClassLoader Component

The ClassLoader component provides tools to autoload your classes and cache their locations for performance.


The ClassLoader component was deprecated in Symfony 3.3 and will be removed in 4.0. As an alternative, use any of the class loading optimizations provided by Composer.


Whenever you reference a class that has not been required or included yet, PHP uses the autoloading mechanism to delegate the loading of a file defining the class. Symfony provides three autoloaders, which are able to load your classes:

Additionally, the Symfony ClassLoader component ships with a wrapper class which makes it possible to cache the results of a class loader.

When using the Debug component, you can also use a special Symfony\Component\Debug\DebugClassLoader that eases debugging by throwing more helpful exceptions when a class could not be found by a class loader.


$ composer require symfony/class-loader:^3.4

Alternatively, you can clone the repository.


If you install this component outside of a Symfony application, you must require the vendor/autoload.php file in your code to enable the class autoloading mechanism provided by Composer. Read this article for more details.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.