title: Symfony Process - execute command from service
body: <p>How can I run a command (app/console execute:my:command)
  in a service via new Process?</p>
  
  <p>I try this:</p>
  
  <pre><code>use Symfony\Component\Process\Process;
  use Symfony\Component\Process\Exception\ProcessFailedException;
  
  $process = new Process(
      'app/console execute:my:command'
  );
  $process-&gt;start();
  </code></pre>
  
  <p>But nothing happens ...
  If I call it manually via terminal it works:</p>
  
  <pre><code>app/console execute:my:command
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <blockquote>
    <p>EDIT - Solution: We need to write the whole path. In my case:</p>
  
  <pre><code>($this-&gt;kernelRootDir is : %kernel.root_dir%)
  </code></pre>
  </blockquote>
  
  <pre><code>$processString = sprintf(
      'php %s/../app/console %s %s',
      $this-&gt;kernelRootDir,
      self::MY_COMMAND,
      $myArgument
  );
  
  $process = new Process($processString);
  $process-&gt;start();
  
  if (!$process-&gt;isSuccessful()) {
      throw new ProcessFailedException($process);
  }
  </code></pre>