arielcr
arielcr

Reputation: 1663

Laravel 4.2 Environments

I've set 2 environments for my app, a local development on my machine and the production environment on the server. I set them in bootstrap/start.phplike this:

$env = $app->detectEnvironment(array(
    'ariel_dev' => array('Ariels-MacBook-Pro.local'),
    'production' => array('my.server.hostname'),
));

I've also set a folder under app/config/ariel_dev where I put the config files which I want to overwrite, like database.php.

I've test them, and they work pretty good. The problem is that my hostname changes when I'm home and when I'm at the office (I'm using a Mac). So the app doesn't match my dev environment and defaults to the production environment, connecting to the database of the server.

I'm doing something wrong? Doesn't it suppose to throw an error or something? Do I've to create a production folder under config?

Hope someone helps!

Upvotes: 1

Views: 2571

Answers (2)

marcanuy
marcanuy

Reputation: 23942

The default environment is always production, so you can leave it out of the array. For the other problem of having two different hostnames for you local dev, you can add them as array values of for the array local environment key.

$env = $app->detectEnvironment(array(
    'ariel_dev' => array('Ariels-MacBook-Pro.local', 'myHomeHostname'),
));

Upvotes: 1

Christopher Pecoraro
Christopher Pecoraro

Reputation: 136

Remember that production is also used as a fallback--it's pretty dangerous as you've configured it.

http://laravel.com/docs/configuration#environment-configuration states:

The default environment is always production

So try something like this:

$env = $app->detectEnvironment(array(
     'productionserver' => array('my.server.hostname'),
     'ariel_dev' => array('Ariels-MacBook-Pro.local'),
    ));

and then use productionserver as the folder instead of ariel_dev

Upvotes: 0

Related Questions