March 19, 2024

The ContactSunny Blog

Tech from one dev to another

Auto-discovery of packages in Laravel 5.5

2 min read

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.

1 thought on “Auto-discovery of packages in Laravel 5.5

  1. Could you add code instead of image? There is no chance for copy/paste so chance appears for mistyping…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.