I have jobs to send several emails.
In my controller I call the job:
dispatch(new SendStartPatEmail($data));
And record is saved in table jobs.
But to execute the job I have to run php artisan queued:work
manually.
How can I do this automatically?
There are lots of different ways, all depending on the environment that you're using. Laravel tends to recommend using Supervisor to monitor your queue workers and keep them running.
Alternatively, you may wish to have your jobs execute immediately, instead of adding them to a queue. You can do this by setting your queue driver to sync
, either in your config:
config/queue.php
'default' => env('QUEUE_DRIVER', 'sync'),
or in your .env
file (assuming your config is set up as above)
.env
QUEUE_DRIVER=sync
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With