6
$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?

3
  • I want to know about this as well :D Commented Jul 16, 2013 at 8:45
  • Have you checked this answer? stackoverflow.com/q/13860283/1317935 Commented Jul 16, 2013 at 10:43
  • Yes I did, that is where I knew about this, but my problem is, only the default configs of laravel are being used here, not the custom ones, my custom one is called "hybridAuth" I place there facebook auth, twitter auth etc Commented Jul 17, 2013 at 9:58

3 Answers 3

7

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

Sign up to request clarification or add additional context in comments.

4 Comments

"The original config files can be used in my local environment like the database.php, cache.php etc. " I said that in my question, my problem is custom made files I made that is inside of the config folder, it doesn't get included in the environment change. Thanks anyway
The local enviroment is not specified then. Try to remove '*.', try 'local' => array('localhost'), which works for me! What is the URL that you use to access your app localy? Is it formated similary to http://subdomain.localhost/?
@Andreyco I needed to define my computer name (for artisan) and the correct domain: 'local' => array('*.dev', 'Eon.local'),
for packages this is: app/config/packages/author/package/environment/config.php github.com/laravel/framework/issues/1255
2

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

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.