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?

Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
Ironwind
  • 1,150
  • 11
  • 18
  • I want to know about this as well :D – Bryan P Jul 16 '13 at 08:45
  • Have you checked this answer? http://stackoverflow.com/q/13860283/1317935 – Laurence Jul 16 '13 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 – Ironwind Jul 17 '13 at 09:58

3 Answers3

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

Andreyco
  • 22,476
  • 5
  • 61
  • 65
  • "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 – Ironwind Jul 17 '13 at 10:00
  • 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 Jul 17 '13 at 10:32
  • 1
    @Andreyco I needed to define my computer name (for artisan) and the correct domain: `'local' => array('*.dev', 'Eon.local'),` – ptim Nov 01 '13 at 08:27
  • for packages this is: `app/config/packages/author/package/environment/config.php` https://github.com/laravel/framework/issues/1255 – ptim Nov 06 '13 at 00:21
2

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

Edwin M
  • 351
  • 3
  • 4
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.

alexdmejias
  • 1,399
  • 4
  • 19
  • 34