Search code examples
phplaravellaravel-4

composer package only for development in laravel providers


If I have a package (that I have to add to app/config/app.php providers/aliases) that I only really want on my development boxes (b/c I only use for development) is there an approach that will allow me to do this leveraging composer require --dev <package> along w/ composer install --no-dev

I need to add an index into both the providers and aliases array...but I would prefer NOT to manage those large arrays in multiple config environment folders if possible


Solution

  • Create a folder in your config directory that matches your environment name. dev in this case.

    Next, recreate any files you wish to override and place them into that folder. app.php in this case

    Next open bootstrap/start.php and find $app->detectEnvironment. The array passed to this method determines which environment you are working with. Setting the key to this array as dev will overwrite any of your config files with their counterparts in your dev folder.

    If you do not wish to create an entirely new providers array in app.php file for each environment and say you only wanted to add a certain provider to your dev environment, you may use a helper method like so...

    'providers' => append_config(array(
        'DevOnlyServiceProvider',
    ))
    

    All this information was pulled from the Laravel documentation found here: http://laravel.com/docs/configuration