Search code examples
laravellaravel-4command-linelaravel-artisanartisan-migrate

Stop artisan from asking "Do you really wish to run this command?"


I'm new in using Laravel 4, running it in my localhost. I would like to know how can I make artisan skip the question asking Do you really wish to run this command? every time I execute migration command? I would just like to execute command immediately without typing y. And also without adding --force in the end of the migration command.

I know the prompt is really important on production but I find it a bit annoying especially when you're in tutorial. I just want to turn it off to make life easier.

Any help would be greatly appreciated.


Solution

  • If you set your environment to local you won't get the warning question, as that is only shown when Laravel detects you're in production, where running migrations by mistake might be dangerous. You can simply add the following in your bootstrap/start.php file:

    $env = $app->detectEnvironment(array(
        // The array value should be your hostname
        'local' => array('your-machine-name'),
    ));
    

    The above will allow Laravel to set the environment to local when it detects that your computer hostname maches the one you specified, thus avoiding displaying the message.


    For more information on configuring environments and the advantages you get from that, read the Laravel Environment Configuration Docs.