Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MohmdDodange's avatar

A way to deal with queue:work without supervisor and cron job

Hello. I'm developing an application that uses the OTP method to login/register. I can't use cron job and supervisor to be sure queue is running all the time, but I need to use queues for sending emails and sms.

so in my OTPController, after dispatching the new job(send email or sms), controller will return to a view for entering confirmation code. then a Fetch API request(from view) will be sent to a route that I created. the Route has a function to check there's a record in the jobs table or not. If table has records, the function will check the OTP token that I sent with fetch api, if the token is correct, function will run this command like this: Artisan::call('queue:work --stop-when-empty'); and the return a json response.

Is this a good practice considering that I can not use cron job and supervisor? Is there a better way to implement queues like this?

0 likes
3 replies
tisuchi's avatar

@mohmddodange Based on my understanding, surely it's not a good practice.

I can foresee performance issue here. For low-traffic applications / specific tasks, it may be suitable, but for high-traffic apps, it will surely be an issue for performance.

Alternatively, you may use (if possible) on-demand workers (AWS lamda/similar queue workers) or any WebSockets.

1 like
og-neth's avatar

I have a low traffic site, essentially its my portfolio site, but I do have a contact form and also another little pop up to generate a lead if someone wants to view a curated version of my portfolio. I host this application on shared hosting with godaddy, I cannot install supervisor, so I am trying to send mail without a queue, since this is very low traffic for sure... is this possible?

JussiMannisto's avatar

@og-neth You can send an email synchronously during the HTTP request, but I wouldn't recommend it. If I were you, I'd try the brand new defer functionality. It allows you to immediately return a response to the client, and send the email afterwards in a separate process.

The feature was just added to Laravel 11 so you may have to update your laravel/framework dependency.

Demo of the feature: https://youtu.be/AwWepVU5uWM?si=sx3qqHCbanIg8i84&t=1891

Edit. The feature is still in beta as mentioned in the docs. I just tried it out for the first time and it's bugged at the moment. I ran into the same issue as this user.

The bug is in how Illuminate\Concurrency\ProcessDriver passes redirection operators, as they're interpreted as being part of a command name. I got it working with small tweaks, so there will probably be an official fix soon.

Please or to participate in this conversation.