9 use Composer\Console\Application;
10 use Composer\IO\BufferIO;
11 use Composer\Factory as ComposerFactory;
12 use Symfony\Component\Console\Output\BufferedOutput;
30 private $composerHome;
37 private $composerJson;
44 private $consoleOutput;
49 private $consoleArrayInputFactory;
54 private $consoleApplication;
68 Application $consoleApplication =
null,
70 BufferedOutput $consoleOutput =
null 72 $this->consoleApplication = $consoleApplication ? $consoleApplication :
new Application();
73 $this->consoleArrayInputFactory = $consoleArrayInputFactory ? $consoleArrayInputFactory
75 $this->consoleOutput = $consoleOutput ? $consoleOutput :
new BufferedOutput();
77 $this->composerJson = $pathToComposerJson;
78 $this->composerHome = $pathToComposerHome;
80 putenv(
'COMPOSER_HOME=' . $pathToComposerHome);
82 $this->consoleApplication->setAutoExit(
false);
93 return ComposerFactory::create(
new BufferIO(), $this->composerJson);
106 $this->consoleApplication->resetComposer();
114 $input = $this->consoleArrayInputFactory->create($commandParams);
116 $exitCode = $this->consoleApplication->run($input, $this->consoleOutput);
119 throw new \RuntimeException(
120 sprintf(
'Command "%s" failed: %s', $commandParams[
'command'], $this->consoleOutput->fetch())
124 return $this->consoleOutput->fetch();
__construct( $pathToComposerHome, $pathToComposerJson, Application $consoleApplication=null, ConsoleArrayInputFactory $consoleArrayInputFactory=null, BufferedOutput $consoleOutput=null)
runComposerCommand(array $commandParams, $workingDir=null)
const COMPOSER_WORKING_DIR