Laravel Package Auto-Discovery


June 6th, 2017

Laravel Package Auto-Discovery

Go out and find a few Laravel packages and read skim through each one’s readme file and see if you notice anything in common. I’ll give you a hint; every Laravel Package outlines the following steps:

Install the package:

composer require foo/bar

Register the provider in app.php:


Optionally, register the Facade:

'Bar' => Foo\Bar\Facade::class,

The steps are far from difficult, but it’s always a requirement, and in the past, people have to get around this by releasing their own package installer, but it never stuck. Probably because it wasn’t directly supported by the framework.

All this is changing and coming in Laravel 5.5 is a brand new way for packages to register their service providers and aliases in the package composer.json file. This saves us the hassle of having to go through all those steps above.

If you are a package developer you can see Taylor’s post on it and see this pull request that was submitted to DebugBar that demonstrates how to set it up or add this to your composer.json:

"extra": {
"laravel": {
"providers": [
"aliases": {
"Bar": "Foo\\Bar\\Facade"

Package auto-discovery is a small change, but it will make installing packages easier and more streamlined than ever before.

Filed in:

Eric L. Barnes

Eric is the creator of Laravel News and has been covering Laravel since 2012.