In Laravel 4 the default configuration environment is \'production\'. This means that if you run an artisan command without the --env
option, it assumes the product
Thanks Antonio for prompting me to reconsider domain detection.
$env = $app->detectEnvironment(array(
(
// Empty string is to set development as the default environment for
// artisan commands.
'development' => array('dev.foo.com', ''),
'test' => array('test.foo.com'),
'production' => array('www.foo.com', 'foo.com'),
));
Adding '' as a development domain effectively sets development as the default environment for artisan commands, presumably because the domain name is blank when the application is invoked from the command line. I tested and it seems anything == false
will work. I also verified this does not interfere with the detection of the production or testing environments.
You can try modifying app/start.php file to add second parameter on desired environment as TRUE i.e. to enable local environment it looks like
$env = $app->detectEnvironment(array(
'local' => array('homestead',true),
));
In bootstrap/start.php you can set the environment:
$env = $app->detectEnvironment(function()
{
return 'development';
});
But you can do many things like:
$env = $app->detectEnvironment(array(
'local' => array('your-machine-name'),
));
And
$env = $app->detectEnvironment(function()
{
return $_SERVER['MY_LARAVEL_ENV'];
});
$env = $app->detectEnvironment(array(
'staging' => array('baichebao_test'),
'local' => array('*.local', '*'),
));
like my example, put your default environment in the last item of array, and add "*" to it's manager hostname. and it works in laravel 4.X
One of the most elegant solution that I've found is from this blog post: http://stevegrunwell.com/blog/laravel-application-environment/
The advantages:
start.php
. environment.php
file.In Laravel 4.2 you will not be able to do destructive artisan migrations without being prompted:
Destructive migration operations now require confirmation or --force when being run in production.
Change log for 4.2 is here