Reputation: 1733
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.
Upvotes: 4
Views: 10375
Reputation: 1837
For a docker prod. deployment, this was added to run artisan migrate
the first time.
BASEDIR="/foo/bar/storage"
if [ ! -f "$BASEDIR/.artisan_init" ]; then
# ...
{ printf "yes\n"; } | ./artisan migrate
date -I > "$BASEDIR/.artisan_init"
# ...
fi
In case there are more than one question to answer, you can pile up answers:
{ printf "yes\n"; printf "foo\n"; printf "bar\n"; } | ./artisan migrate
Upvotes: 0
Reputation: 3423
Adding more to Bogdan's answer and comments.
In case you are not familiar with the concept of environments in Laravel, it's there to specify different configurations specific to the environment your application runs in. For example you will have different database credentials in your local env than the live server (production env).
So one reason why you shouldn't use 'local' => array(gethostname())
is that this would make your environment local
regardless of where you run this (your local machine, testing env or production).
This is the preferred method of determining the env
$env = $app->detectEnvironment(function() {
return getenv('APP_ENV') ? : 'production';
});
So unless you have an environment variable set in your VHOST file, it will default to production.
But since you don't have anyway to specify your env variables, I suggest you stick to Bogdan's solution.
Upvotes: 1
Reputation: 44526
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.
Upvotes: 4