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.
Calls artisan console command in background, with optional
call_in_background('foo'); // "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!