Package Auto-Discovery In Laravel 5.5
For Laravel 5.5, which is due for release near the end of July or beginning of August, long time community member Dries Vints and I teamed up to make it much easier to install and enable packages.
Package developers will now be able to add a new section to their
composer.json files that inform the framework of any service providers or facade aliases that should be registered. In fact, I have already submitted a pull request to add this configuration to the popular “Laravel Debugbar” package by Barry vd. Heuvel.
Now, on a fresh copy of Laravel 5.5, I can simply require the package:
composer require barryvdh/laravel-debugbar:dev-master
And the package’s service provider will automatically be registered and enabled:
This eliminates much of the headache around installing and consuming packages. For example, if an auto-discovery enabled Composer package is installed in the
require-dev portion of your
composer.json file, its service provider will only be registered when your “dev” dependencies are installed. This is fantastic for packages like Laravel Dusk that should only be available in a “dev” environment. No more conditional service provider registration cluttering up your
Of course, we can easily remove installed packages and their discovered providers and aliases will be removed as well:
composer remove barryvdh/laravel-debugbar
It is also easy to disable auto-discovery for one or more packages by listing them in a
dont-discover portion of your application’s
This addition to Laravel 5.5 makes it a cinch to start using all kinds of community developed packages. I can’t wait for you to try it.