當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Command::run方法代碼示例

本文整理匯總了PHP中Illuminate\Console\Command::run方法的典型用法代碼示例。如果您正苦於以下問題:PHP Command::run方法的具體用法?PHP Command::run怎麽用?PHP Command::run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Console\Command的用法示例。


在下文中一共展示了Command::run方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Override run method to internationalize error message.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int Return code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // Set extra colors
     // The most problem is $output->getFormatter() don't work.
     // So create new formatter to add extra color.
     $formatter = new OutputFormatter($output->isDecorated());
     $formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
     $formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
     $formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
     $formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
     $formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
     $formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
     $output->setFormatter($formatter);
     \App::setLocale(\Config::get('syncle::MessageLang'));
     try {
         $result = parent::run($input, $output);
     } catch (\RuntimeException $e) {
         // All error messages were hard coded in
         // Symfony/Component/Console/Input/Input.php
         if ($e->getMessage() == 'Not enough arguments.') {
             $this->error(\Lang::get('syncle::BaseCommand.ArgumentNotEnough'));
         } elseif ($e->getMessage() == 'Too many arguments.') {
             $this->error(\Lang::get('syncle::BaseCommand.TooManyArgument'));
         } elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
             $this->error(\Lang::get('syncle::BaseCommand.OptionNotExist', array('option' => $matches[1])));
         } else {
             $this->error($e->getMessage());
         }
         $result = 1;
     }
     return $result;
 }
開發者ID:hirokws,項目名稱:syncle,代碼行數:39,代碼來源:BaseCommand.php

示例2: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     // Set extra colors.
     // The most problem is $output->getFormatter() don't work...
     // So create new formatter to add extra color.
     $formatter = new OutputFormatter($output->isDecorated());
     $formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
     $formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
     $formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
     $formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
     $formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
     $formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
     $output->setFormatter($formatter);
     return parent::run($input, $output);
 }
開發者ID:paramonovav,項目名稱:laravel-optimize-images,代碼行數:15,代碼來源:BaseCommand.php

示例3: run

 /**
  * Symfonyコマンドコンポーネントにハードコードされている
  * エラーメッセージを日本語に変換する.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int Return code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     try {
         $result = parent::run($input, $output);
     } catch (\RuntimeException $e) {
         if ($e->getMessage() == 'Not enough arguments.') {
             throw new \RuntimeException(__('引數が足りません。'), $e->getCode(), $e->getPrevious());
         } elseif ($e->getMessage() == 'Too many arguments.') {
             throw new \RuntimeException(__('引數が多すぎます。'), $e->getCode(), $e->getPrevious());
         } elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
             throw new \RuntimeException(__($matches[1] . 'オプションは存在していません。'), $e->getCode(), $e->getPrevious());
         } else {
             throw new \RuntimeException($e->getMessage(), $e->getCode(), $e->getPrevious());
         }
     }
     return $result;
 }
開發者ID:HiroKws,項目名稱:zakkuto-laravel-hub-site,代碼行數:26,代碼來源:BaseCommand.php

示例4: run

 /**
  * Override run method to internationalize error message.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int Return code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     try {
         $result = parent::run($input, $output);
     } catch (\RuntimeException $e) {
         // All error messages were hard coded in
         // Symfony/Component/Console/Input/Input.php
         if ($e->getMessage() == 'Not enough arguments.') {
             $this->error(\Lang::get('StriveJobs::BaseCommand.ArgumentNotEnough'));
         } elseif ($e->getMessage() == 'Too many arguments.') {
             $this->error(\Lang::get('StriveJobs::BaseCommand.TooManyArgument'));
         } elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
             $this->error(\Lang::get('StriveJobs::BaseCommand.OptionNotExist', array('option' => $matches[1])));
         } else {
             $this->error($e->getMessage());
         }
         $result = 1;
         // As error status code
     }
     return $result;
 }
開發者ID:hirokws,項目名稱:strivejobs,代碼行數:28,代碼來源:BaseCommand.php

示例5: runCommand

 protected function runCommand(Command $command, array $input, OutputInterface $output)
 {
     $command->setLaravel($this->app);
     return $command->run(new ArrayInput($input), $output);
 }
開發者ID:gummibeer,項目名稱:backuplay,代碼行數:5,代碼來源:TestCase.php

示例6: run

 /**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     app(ConsoleOutput::class)->setOutput($this);
     return parent::run($input, $output);
 }
開發者ID:ericmakesstuff,項目名稱:laravel-server-monitor,代碼行數:11,代碼來源:BaseCommand.php

示例7: runCommand

 /**
  * Run the command.
  * @param \Illuminate\Console\Command $command
  * @param array $input
  * @return int
  */
 protected function runCommand($command, $input = [])
 {
     return $command->run(new ArrayInput($input), new NullOutput());
 }
開發者ID:micheleangioni,項目名稱:laravel-js-lang-converter,代碼行數:10,代碼來源:LangJsCommandTest.php

示例8: run

 /**
  * run.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return \Symfony\Component\Console\Input\StringInput
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     $command = (string) $input;
     $command = strtr($command, [' -name' => ' -N', ' -type' => ' -T', ' -maxdepth' => ' -M', ' -delete' => ' -d true']);
     return parent::run(new StringInput($command), $output);
 }
開發者ID:recca0120,項目名稱:laravel-terminal,代碼行數:14,代碼來源:Find.php

示例9: invokeCommand

 /**
  * @param \Illuminate\Console\Command $mockedCommandObject
  * @param array $arguments
  * @return int
  */
 public function invokeCommand(Command $mockedCommandObject, $arguments = [])
 {
     $mockedCommandObject->setLaravel(app());
     return $mockedCommandObject->run(new ArrayInput($arguments), $this->getCommandOutput());
 }
開發者ID:skimia,項目名稱:foundation,代碼行數:10,代碼來源:CommandTrait.php

示例10: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     $options = $input->__toString();
     $arr = explode(' ', $options);
     array_shift($arr);
     foreach ($arr as $i => &$option) {
         $option = trim($option, "'");
         if (strpos($option, '-') === 0) {
             $option = '{' . $option . '?}';
         } else {
             $option = '{k' . $i . '}';
         }
     }
     $this->signature = implode(' ', $arr);
     $this->configureUsingFluentDefinition();
     $this->setDescription($this->description);
     return parent::run($input, $output);
 }
開發者ID:garveen,項目名稱:imagist-old,代碼行數:18,代碼來源:Composer.php


注:本文中的Illuminate\Console\Command::run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。