I'm new in Yii2, now I'm using Yii2 with the advance template.
In my project, I need my application can read database using AJAX, and also run in background task. It's like a Cron Job, but I don't know how to do it.
Anyway, I want to integrate sms-gateway services, so when I create some request, it send SMS to user, and user can send SMS to the application with some format. And the SMS from user, it will be used to do another action in my project.
After all, I just can send SMS from my application to user, but cannot read SMS that send from user, and then I can't trigger another action.
Just the same on Yii2 Forum over here!
I got the answer. I use infinite loop with sleep in 1 second. So it will check the database every seconds, that do action that check incoming sms and auto reply the sms.
while (true) {
/*Other script that will read sms , and reply sms*/
sleep(1);
//Or use usleep to use sleep in microsecond
}
more about sleep