/**
  *
  * @return string
  * @throws \Exception
  */
 public function actionInstall()
 {
     $composer = $this->getComposer();
     $cmd = new RequireCommand();
     $input = new ArrayInput(['packages' => ['rmrevin/yii2-fontawesome']]);
     $output = new BufferedOutput();
     $app = new Application();
     $io = new BufferIO();
     $composer->getConfig()->getRepositories();
     $cmd->setComposer($composer);
     $cmd->setApplication($app);
     $cmd->setIO($io);
     $result = '';
     if ($cmd->run($input, $output)) {
         $result = $output->fetch();
     }
     return $this->render('install', ['result' => $result]);
 }
示例#2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $newWorkDir = $this->getNewWorkingDir($input);
     if (!is_dir($newWorkDir)) {
         throw new \RuntimeException("Not found directory:" . $newWorkDir);
     }
     $oldWorkingDir = getcwd();
     chdir($newWorkDir);
     $io = new ConsoleIO($input, $output, $this->getHelperSet());
     $composer = Factory::create($io);
     $this->setComposer($composer);
     $this->setIO($io);
     $statusCode = parent::execute($input, $output);
     if (isset($oldWorkingDir)) {
         chdir($oldWorkingDir);
     }
     return $statusCode;
 }