Laravel queues on localhost

In the PHP framework Laravel within production environments, workers and supervisors ensure that the jobs stored in, for example, Redis are processed. If you want to be completely independent of this on localhost, you can either use the sync driver to always execute the jobs immediately. This has the disadvantage that the current PHP process is blocked and the request hangs until the job has been processed.


It is better to call another PHP instance that initiates a one-time worker pass. The following implementation also takes care of Windows / Mac / Linux differences. We first define a job in the usual way:

e24ced88a284d02f2ab5c64bb5905fce

Then we create a general helper that takes care of the execution:

e24ced88a284d02f2ab5c64bb5905fce

Finally, we call this function in a controller:

e24ced88a284d02f2ab5c64bb5905fce

Back