PSR Librairies from composer
PSR-4 Autoloader
Install PSR-4 Autoloader
copy to clipboard{ "autoload": { "psr-4": { "App\\": "src/" } } }
Include in PHP file
copy to clipboardrequire('vendor/autoload.php');
Autoloader Optimization
By default, the Composer autoloader runs relatively fast. However, due to the way PSR-4 and PSR-0 autoloading rules are set up, it needs to check the filesystem before resolving a classname conclusively. This slows things down quite a bit, but it is convenient in development environments because when you add a new class it can immediately be discovered/used without having to rebuild the autoloader configuration.The problem however is in production you generally want things to happen as fast as possible, as you can simply rebuild the configuration every time you deploy and new classes do not appear at random between deploys.
For this reason, Composer offers a few strategies to optimize the autoloader.
The offical post can be found here : autoloader optimization