/** * @param string $name * @param $args * @return mixed * @throws Exception */ public function call($name, array $args) { if (!$this->child->isRunning()) { throw new Exception('Child Process died'); } return $this->protocol->sendCall($name, $args); }
/** * @return StreamProcess * @throws Exception */ private function spawnChildProcess() { $childBin = $this->childBinPath; if (!is_file($childBin)) { throw new Exception('child.php not found generate it using bin/generateChild.php'); } $cwd = false; if ($this->workingDirectory) { $cwd = getcwd(); chdir($this->workingDirectory); } $cmd = sprintf('%s %s %s', $this->phpPath, $this->compileArgs(), escapeshellarg(realpath($childBin))); $child = new StreamProcess($cmd); if ($cwd) { chdir($cwd); } if (!$child->isOpen() || !$child->isRunning()) { throw new Exception('Failed to spawn child process'); } return $child; }