How to enable custom configuration for another environment in Laravel-4

$env = $app->detectEnvironment(array( 'local' => array('*.local'), )); 

The source configuration files can be used in my local environment, for example, database.php , cache.php , etc. But my custom configuration is not used in my local environment.

Is there any way to add my custom configuration to it?

+6
source share
3 answers

First you need to determine what a "local" environment is.

 $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 a directory called local in app/config . If you want to override database settings in local env. create a file: app/config/local/database.php and override the parameter in this file, for example:

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

In this file you do not need to specify all parameters, only parameters other than the production / base configuration.

Additional information in official docs

+7
source

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

+2
source

I know this is pretty late, but it can help someone who gets into this thread. To answer the question about loading custom configuration files, you can find it here . I have not seen it anywhere in the docs, but all you have to do is just create a new directory in config/ with the name of your environment. Duplicate the file you want to overwrite to the new directory, and edit the settings. While you are in this file, you can also delete anything that is not overwritten.

0
source

Source: https://habr.com/ru/post/949537/


All Articles