Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

StarTrix's avatar

Running Artisan commands from code

I can call this command: Artisan::call('migrate') perfectly locally, but from a live host I can not. I assume it is because it needs to confirm first .. so, I tried this: Artisan::call('migrate', ["--no-interaction"=>true ]) And tried "yes" instead of true but no luck at all..

Please help!!

0 likes
8 replies
connorhood's avatar

Shouldn't it be:

Artisan::call('migrate', ["--force"=> true ])
5 likes
connorhood's avatar

@startrix - I am not sure where you found --no-interaction for. The --force option is how you force a migration when in production.

connorhood's avatar

Here is the output I get from running artisan help migrate:

vagrant@homestead:~/code/written$ php artisan help migrate
Usage:
 migrate [--bench[="..."]] [--database[="..."]] [--force] [--path[="..."]] [--package[="..."]] [--pretend] [--seed]

Options:
 --bench               The name of the workbench to migrate.
 --database            The database connection to use.
 --force               Force the operation to run when in production.
 --path                The path to migration files.
 --package             The package to migrate.
 --pretend             Dump the SQL queries that would be run.
 --seed                Indicates if the seed task should be re-run.
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question
 --env                 The environment the command should run under.

queenqueen's avatar

I have question ,how can we run php artisan queue:listen from code?

zakir1929's avatar

Hi, How can I run below command in octobercms by php code.

"php artisan plugin:refresh Acme.Demo"

I don't have ssh access that is why I need that, please.

Please or to participate in this conversation.