Run Laravel Command Using Link and Run in teh Background
Hello guys,
Is there any way to run a laravel artisan command using a link and run the script in the background so user won't have to wait the script finish processing.
For example : I have a command called auto:like. User click on link localhost/run/like and execute the command auto:like in the background. Once finished, a notification send to user that the task have been completed. I can't use cron because my hosting provider not allowed me to do so. thanks.
Not sure about your notification though, that would depend on how you want to notify them. Email? Popup on website? You can fire an event when the task completes and listen for it and handle it how you wish.
@Cronix thanks for your answer. Don't mind about the notification already implemented it using OnePush notification.
So let's say user click on the link, how to display on the front end that the script is running, and user's browser stop loading (without the user stop it manually) while in the background the script is processing.
Probably the best way is to use a queue for processing your long job. That way you don't need the above and the user doesn't have to wait.
The other way is probably with a javascript redirect, or have a popup show up telling the user that their job is being processed and click "this link" to continue. Link takes them to a different page. Otherwise it will sit there loading until it's completed its task. The job would still be running in the background though and user can close tab or browser and it will continue.