Laravel Package Auto-Discovery

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: Laravel 5.5 / Composer


Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Laravel Partner Seeks Team Lead / Developer
Kirschbaum Development Group, LLC
Lead Developer/Director of Technology
Hamilton, Ontario, Canada
Qualify EHS - A Worksite Safety Company
Engineering Director
Vancouver or remote (EST/PST preferred)
Engine Digital
Full-Stack Engineer
Vancouver or remote (EST/PST preferred)
Engine Digital
Sr. Software Engineer
Boca Raton - Florida, Remote - USA Only