3 years ago

Console command call in background

Posted 3 years ago by dmitry.g.ivanov

Hi there!

If you need to call artisan command from code, you can use Laravel Artisan facade class:

But what about background calls?

I've made a simple helper function for that.

call_in_background() Calls artisan console command in background, with optional before and after sub-commands:


// "php artisan foo" would be called in background
call_in_background('foo:bar baz', 'sleep 0.3');

// "sleep 0.3 && php artisan foo:bar baz" would be called in background

If you'd like to use it, this helper is available in my package with other helper functions:

Hope it would be useful for someone. Thanks and have a great day!

Please sign in or create an account to participate in this conversation.