Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I trigger Laravel jobs from a controller instead of using the `php artisan queue` process

We are running our production system on Elastic Beanstalk. We want to be able to take advantage of EBS' worker tiers with autoscaling. Unfortunately, due to how Laravel queue processing works, Laravel expects all queues to be consumed by starting a php command line process on your servers. EBS worker tiers don't function that way. AWS installs a listener daemon of its own, that pulls of jobs and feeds them to your worker over local HTTP calls. Sounds great. Unfortunately, I can't figure out how one would call a queued job from a route and controller in Laravel instead of using the built-in artisan queue listener task. Any clues as to how to achieve this would be greatly appreciated.

like image 848
Sam McAfee Avatar asked Mar 13 '23 09:03

Sam McAfee


1 Answers

You can use the Artisan::call method to call commands from code.

$exitCode = Artisan::call('queue:work');

You can see more info in the docs

like image 65
jfadich Avatar answered Apr 28 '23 08:04

jfadich