I would create a background task that loops continuously with Symfony2
I want to know how to do this
protected function execute(){
while (true) {
sleep(60);
//------------ do some think
}}
I would create a background task that loops continuously with Symfony2
I want to know how to do this
protected function execute(){
while (true) {
sleep(60);
//------------ do some think
}}
As far as I know, PHP doesn't have threading, so you won't be able to run that in parallel with your Symfony application.
Instead, create a cron job which executes that code via CLI.
Here's a pretty straight-forward intro to cron jobs.
If you're on a Windows server, set up a scheduled task. See How to run a PHP file in a scheduled task (Windows Task Scheduler).