Ironwind
Ironwind

Reputation: 1220

How to include custom config for different environment in Laravel-4

$env = $app->detectEnvironment(array(

    'local' => array('*.local'),

));

The original config files can be used in my local environment like the database.php, cache.php etc. But my custom config isn't getting used in my local environment.

Is there a way to add my custom config on it?

Upvotes: 6

Views: 8298

Answers (3)

alexdmejias
alexdmejias

Reputation: 1419

I know this is kind of late but it might help somebody who ends up in this thread. To answer your question of loading custom config files, you can find more details here. I didn't see it anywhere in the docs, but all you have to do is just make a new directory in your config/ with the name of your environment. Duplicate the file that you want to overwrite to your new directory and edit the settings. While you are in that file you can also remove everything that is not being overwritten.

Upvotes: 0

Edwin M
Edwin M

Reputation: 361

If you are on Linux and Mac, you may determine your "hostname" using the "hostname" terminal command and use it in the array.

Upvotes: 2

Andreyco
Andreyco

Reputation: 22862

First, you need to define, what is 'local' environment

$env = $app->detectEnvironment(array(
    // everything that contains 'localhost' or '127.0.0.1'
    // in URL will be considered to run in local env.
    'local' => array('localhost', '127.0.0.1'),

));

Then, you need to create directory named local in app/config. If you want to override DB settings in local env. create the file: app/config/local/database.php and override setting in this file, for example:

'connections' => array(

    'mysql' => array(
        'username'  => 'otherUserName',
        'password'  => 'otherPassword',
    ),

), 

In this file, you do not need to specify all options, only options that are different from production/base configuration.

More info in official docs

Upvotes: 7

Related Questions