So many times we find ourselves registering Service Providers that are only needed during development in the providers array. This could slow down our application by registering providers that we do not need in production.
This packages helps you boost your application by only registring these packages in the development environments.
This packages works for Laravel versions 5.* only.
First install the package using your main ally: composer
composer require percymamedy/laravel-dev-booter
Add the Service Provider to your providers array in config/app.php
'providers' => [
...
PercyMamedy\LaravelDevBooter\ServiceProvider::class,
],
Once installed you can now publish your config file and set your correct configuration for using the package.
php artisan vendor:publish --provider="PercyMamedy\LaravelDevBooter\ServiceProvider" --tag="config"
This will create a file config/dev-booter.php
.
You may now set your development environments in config/dev-booter.php
'dev_environments' => [
'local',
'dev',
'testing'
],
You can also set where you want your dev ServiceProviders to be loaded from.
'dev_providers_config_key' => 'app.dev_providers'
You can also specify where you want to place your dev class aliases.
'dev_aliases_config_key' => 'app.dev_aliases'
Now all you need is to set your Dev ServiceProviders in config/app.php
as you would for regular
ServiceProviders. Except that now there is a clean separation of the two and unwanted ServiceProviders will
not be loaded or registered in your production environment.
'dev_providers' => [
...
]
You may also boot class aliases that may only be used on dev enviroment. You only need to add to your config/app.php
the key 'dev_aliases'
and place all your dev class aliases there. Now those aliases or facades will only
be booted on development.
'dev_aliases' => [
...
]
Twitter: @PercyMamedy
GitHub: percymamedy