setup = $setup; $this->phpExecutable = $phpExecutable; $this->composer = $pluginsDirectory . DIRECTORY_SEPARATOR . 'composer.phar'; } public function __destruct() { @unlink($this->composer); } public function install($directory) { $process = $this->createProcessBuilder() ->setTimeout(null) ->add('install') ->add('--working-dir') ->add($directory) ->add('--no-dev') ->add('--optimize-autoloader') ->getProcess(); try { $process->run(); } catch (ProcessException $e) { throw new ComposerInstallException(sprintf('Unable to composer install %s', $directory), $e->getCode(), $e); } if (!$process->isSuccessful()) { throw new ComposerInstallException(sprintf('Unable to composer install %s', $directory)); } } /** * @return ProcessBuilder */ private function createProcessBuilder() { if (!file_exists($this->composer)) { try { $this->setup->setup($this->composer); } catch (RuntimeException $e) { throw new ComposerInstallException('Unable to install composer.', $e->getCode(), $e); } } else { $process = ProcessBuilder::create([ $this->phpExecutable, $this->composer, 'self-update' ])->getProcess(); $process->run(); } return ProcessBuilder::create([$this->phpExecutable, $this->composer]); } }