pmiranda
pmiranda

Reputation: 8420

Laravel, call Artisan from php differs from command line

I have a route which calls the Artisan facade to execute:

Artisan::call('queue:work --once');

And I get :

enter image description here

But it's strange because in the command line, if i do:

php artisan queue:work --once

Works everything ok:

enter image description here

I can use other routes to call for example:

Artisan::call('config:clear');

And works ok too. Any idea?

Upvotes: 0

Views: 664

Answers (3)

Mohamed Waheed
Mohamed Waheed

Reputation: 64

Laravel 5.8 introduced this new method of calling artisan commands:

Artisan::call('queue:work --once');

In previous releases use this:

Artisan::call('queue:work', ['--once' => true]); 

Upvotes: 1

DerDjamel
DerDjamel

Reputation: 114

to call an artisan command from the code and passing some options you need to use an array as a 2nd argument to Artisan::call()

like so :

Artisan::call('queue:work', ['--once' => true]); // or whatever options you need

Upvotes: 0

ahmed galal
ahmed galal

Reputation: 269

the options value staring with -- are not passed to the string you can try :

Artisan::call('queue:work', ['--once' => true]); 

Upvotes: 3

Related Questions