In the PHP framework Laravel, within production environments, workers like the supervisor ensure that jobs stored in Redis , for example, are executed. If you want to be completely independent of this on localhost, you can use the sync driver to execute jobs immediately. However, this has the disadvantage that the current PHP process is blocked, and the request hangs until the job has finished.
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