A simple way to selectively load dev packages into Laravel
NOTE: 18 October 2017
So with the release of Laravel 5.5, this isn’t really needed anymore. Laravel 5.5 now has a package discovery feature so there is no need to add supported packages to your
app.php config anymore. Simply install the package and you’re good to go.
Here’s a little snippit I use all the time. It allows you add packages to your Laravel installation selectively based on the environment you’re working in. There’s always those dev packages you don’t want, or shouldn’t have in production, so they get added to
require-dev. Cool, but then you have non-production packages all over your
app.php config file in production code. I think that’s crap.
So I wrote a super-simple Service Provider for Laravel that will let you load dev packages ONLY when working in your dev environment.
Stick it in your
Providers directory, and add the following line to the
$providers array in
Now you can add your dev packages to the
$providers member array and they’ll only get loaded when your
local. You can also load facades selectively by listing them in the
$facades member array.