Discussion:
Run Symfony2 console command in background from a controller
Nicolò Pignatelli
2012-12-12 11:39:45 UTC
Permalink
Is there a way to run a Symfony2 console command *in background* from a
controller?

I checked the Process component but I'm not sure it suites my case...
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Sebastian Krebs
2012-12-12 11:44:19 UTC
Permalink
$ nohup app/console my:command &

Something like this? Could you describe your problem a little bit further?
Maybe you are looking for something different.
Post by Nicolò Pignatelli
Is there a way to run a Symfony2 console command *in background* from a
controller?
I checked the Process component but I'm not sure it suites my case...
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
github.com/KingCrunch
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Nicolò Pignatelli
2012-12-12 11:50:07 UTC
Permalink
Yes, Sebastian, something like tha, but I need to run it from a controller
and I was wondering if it was ok to execute a line like that from there.
What I ideally want is that after, let's say, a user saves an object
through a form, that command is started in background while the user can
already see the web response

Don't know if it's clearer now...

Il giorno mercoledì 12 dicembre 2012 12:44:19 UTC+1, Sebastian Krebs ha
Post by Sebastian Krebs
$ nohup app/console my:command &
Something like this? Could you describe your problem a little bit further?
Maybe you are looking for something different.
Post by Nicolò Pignatelli
Is there a way to run a Symfony2 console command *in background* from a
controller?
I checked the Process component but I'm not sure it suites my case...
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
github.com/KingCrunch
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Sebastian Krebs
2012-12-12 13:10:43 UTC
Permalink
Post by Nicolò Pignatelli
Yes, Sebastian, something like tha, but I need to run it from a controller
and I was wondering if it was ok to execute a line like that from there.
What I ideally want is that after, let's say, a user saves an object
through a form, that command is started in background while the user can
already see the web response
Depending on what you are trying to do (especially: how much) you could use
the 'kernel.terminate'-event instead of a new process.
Post by Nicolò Pignatelli
Don't know if it's clearer now...
Il giorno mercoledì 12 dicembre 2012 12:44:19 UTC+1, Sebastian Krebs ha
Post by Sebastian Krebs
$ nohup app/console my:command &
Something like this? Could you describe your problem a little bit
further? Maybe you are looking for something different.
Post by Nicolò Pignatelli
Is there a way to run a Symfony2 console command *in background* from a
controller?
I checked the Process component but I'm not sure it suites my case...
--
If you want to report a vulnerability issue on symfony, please send it
to security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/**group/symfony2?hl=en<http://groups.google.com/group/symfony2?hl=en>
--
github.com/KingCrunch
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
github.com/KingCrunch
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Nicolò Pignatelli
2012-12-12 12:07:47 UTC
Permalink
Solved:

$kernel = $this->get('kernel');
$process = new \Symfony\Component\Process\Process('nohup php '.
$kernel->getRootDir() .'/console my:console:command --env='.
$kernel->getEnvironment() .' > /dev/null 2>&1 &');
$process->run();

Il giorno mercoledì 12 dicembre 2012 12:39:45 UTC+1, Nicolò Pignatelli ha
Post by Nicolò Pignatelli
Is there a way to run a Symfony2 console command *in background* from a
controller?
I checked the Process component but I'm not sure it suites my case...
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Nurlan Turdaliev
2012-12-13 11:18:43 UTC
Permalink
You should better use a worker for it. Take a look at Gearman or php-resque
Post by Nicolò Pignatelli
Is there a way to run a Symfony2 console command *in background* from a
controller?
I checked the Process component but I'm not sure it suites my case...
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
--
If you want to report a vulnerability issue on Symfony, please read the procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Loading...