how to use Background worker in Yii ? Please help me.Thanks
how to use Background worker in Yii ? Please help me.Thanks
I don’t think that’s a thing in PHP. In general, if you need to have something running in the background, you can use a cron job to trigger an activity periodically, allowing you to process a queue of actions.
thanks. i want to save a Form data in to Database and send a email and sms to user.but this work take so time.thanks for your Reply.
Okay. Do you need any further help?
Yes ,if may be Please.Thanks
Have a look at the information in this wiki. It’s intended to help you create a mail queue, but the idea is similar.
In essence, you need to maintain a queue of requests, along with all the details you need to process them, in a database table.
Next, create a console command to pick outstanding requests from the queue, process them, then update the table (removing the item or marking it complete).
Finally, create a cron job that runs periodically to start your console command.
You’ll need to add some additional complexity to make it more robust. For instance, you might want to have several states for the request, ‘pending’, ‘in-progress’ and ‘complete’. You could set the state to ‘in-progress’ when you first fetch it for processing to prevent it from being fetched again by another run of the console command. If you did that, you’d want to track how long the request was ‘in-progress’ to prevent failed runs from leaving requests in the queue indefinitely.
If you encounter any specific problems, feel free to post back here and someone will very likely help.
Ok thanks.i test you good idea;Thanks.