02
- June
2017
Posted By : Sunny Srinidhi
Auto-discovery of packages in Laravel 5.5

Laravel 5.5 is right around the corner, and there are quite a few amazing features coming with this new version. Taylor Otwell has been writing about the framework’s new features frequently. The latest feature that he has announced is the auto-discovery of packages, their service providers, and facade aliases. This means, starting Laravel 5.5, we’ll not have to manually copy-paste anything to the providers and the aliases array in app.php in the config folder.

So, if a package you’re installing via composer has the required configuration in it’s composer.json file, the framework will automatically register any providers and aliases provided by the package. Taylor Otwell also mentioned that he has already sent a pull request to the Laravel Debugbar package by Barry vd. Heuvel.

So, for example, if you’re requiring this package in your project, all you have to do is:

composer require barryvdh/laravel-debugbar:dev-master

And that’s pretty much it. No more fiddling with app.php. Also, if the package you’re requiring is a dev-dependency, then the providers and the aliases will be registered only in your dev environment. There’s no need to write any conditional registration of packages.

If, for some reason, you want to disable auto-discovery of one or more packages in your project, you can add those packages in a new “dont-discover” block in your composer.json, as showin the image below.

This leads to a huge improvement in the software development life cycle as we don’t have to worry about registering the right providers and aliases anymore.

Leave a Reply