Search code examples
phplaravellaravel-4

Laravel 4.2 says my application is in production. How do I turn this off?


I have a fresh install of Laravel. When running php artisan migrate:refresh I get a message saying Application In Production! Do you really wish to run this command?'

I know this is an update in 4.2, however I can't figure out how to turn it off.

I found in the source that it comes from Illuminate\Console\ConfirmableTrait and runs if this if test passes : if ($this->getLaravel()->environment() == 'production')

I'm not sure why it thinks I'm in production. I never setup any environments. This is the default environment detection, which I'm still currently using.

$env = $app->detectEnvironment(array(

    'local' => array('homestead')

));

Also, if I set a production environment to a hostname that isn't my machine, I still have the same problem.


Solution

  • Just specify a machine name for the host that matches a given environment, then laravel will automatically detect the environment (default is production), for example:

    $env = $app->detectEnvironment(array(
    
        //'local' => array('homestead'),
    
        'local' => array('*.dev', gethostname()),
        'production' => array('*.com', '*.net', 'www.somedomain.com')
    ));
    

    Read the documentation and this answer as well.