/** * {@inheritdoc} */ public function start() { if ($this->phantomJsProc !== null) { return parent::start(); } $cmd = sprintf('exec %s --webdriver=%d', $this->phantomJsBin, $this->wdPort); try { $this->phantomJsProc = new Process($cmd); $this->phantomJsProc->start(); } catch (\Exception $e) { throw new DriverException('Could not start PhantomJs', 0, $e); } if (!$this->phantomJsProc->isRunning()) { throw new DriverException('Could not confirm PhantomJs is running'); } // give PhantomJs a chance to start before creating a session sleep(1); parent::start(); }