title: Asynchronously calling a Command in Symfony2
body: <p>I want to asynchronously call a Command from within a Controller in Symfony2.</p>
  
  <p>So far i found the following solution:</p>
  
  <pre><code>$cmd = $this-&gt;get('kernel')-&gt;getRootDir().'/console '.(new MLCJobWorkerCommand)-&gt;getName().' '.$job-&gt;getId().' 2&gt;&amp;1 &gt; /dev/null';
  $process = new Process($cmd);
  $process-&gt;start();
  </code></pre>
  
  <p>Is there a better way to accomplish this?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I need the Process to run in background and the Controller to return right after it started the former. I tried:</p>
  
  <pre><code>$cmd = $this-&gt;get('kernel')-&gt;getRootDir().'/console '
       .(new MLCJobWorkerCommand)-&gt;getName()
       .' '.$job-&gt;getId().' 2&gt;&amp;1 &gt; /dev/null &amp; echo \$!';
  $process = new Process($cmd);
  $process-&gt;mustRun();
  $params["processid"] = $process-&gt;getOutput();
  </code></pre>
  
  <p>but the Controller doesn't return a Response until the Process has finished.</p>