I am using JMSJobQueueBundle ( Github , docs ) to create background processes and store the queue (with metadata) in the database.
After installing this package, you simply save the task in your database using the command (and optional arguments and options):
$job = new Job('my-symfony2:command', array('some-args', 'or', '--options="foo"')); $em->persist($job); $em->flush($job);
The package executes this command (after setting up supervisord or cron job), and it stores the output of your command in the database. If your job does not work, it even stores the stack trace in the database. Now you can get the job status in your application (you can use $job->getState() to find out if it is finished or not). You can find the Job object here to see what is stored in the database by default.
I used this method when sending many emails or creating large csv export shipments and it works great.
source share