0]; static $events = [ Events::SUITE_BEFORE => 'runProcess', Events::SUITE_AFTER => 'stopProcess' ]; protected $processes = []; public function _initialize() { if (!class_exists('Symfony\Component\Process\Process')) { throw new ExtensionException($this, 'symfony/process package is required'); } } public function runProcess() { $this->processes = []; foreach ($this->config as $key => $command) { if (!$command) { continue; } if (!is_int($key)) { continue; // configuration options } $process = new Process($command, $this->getRootDir(), null, null, null); $process->start(); $this->processes[] = $process; $this->output->debug('[RunProcess] Starting '.$command); } sleep($this->config['sleep']); } public function __destruct() { $this->stopProcess(); } public function stopProcess() { foreach (array_reverse($this->processes) as $process) { /** @var $process Process **/ if (!$process->isRunning()) { continue; } $this->output->debug('[RunProcess] Stopping ' . $process->getCommandLine()); $process->stop(); } $this->processes = []; } }