当前位置: 首页>>代码示例>>PHP>>正文


PHP Command::run方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Command\Command::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::run方法的具体用法?PHP Command::run怎么用?PHP Command::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Command\Command的用法示例。


在下文中一共展示了Command::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check

 /**
  * Perform the actual check and return a ResultInterface
  *
  * @return ResultInterface
  * @throws \Exception
  */
 public function check()
 {
     $exitCode = $this->command->run($this->input, $this->output);
     $data = [];
     if ($this->output instanceof PropertyOutput) {
         $data = $this->output->getMessage();
         if (!is_array($data)) {
             $data = explode(PHP_EOL, trim($data));
         }
     }
     if ($exitCode < 1) {
         return new Success(get_class($this->command), $data);
     }
     return new Failure(get_class($this->command), $data);
 }
开发者ID:abacaphiliac,项目名称:doctrine-orm-diagnostics-module,代码行数:21,代码来源:CheckCommand.php

示例2: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     // Store the input and output for easier usage
     $this->input = $input;
     $this->output = $output;
     parent::run($input, $output);
 }
开发者ID:bonndan,项目名称:release-manager,代码行数:7,代码来源:BaseCommand.php

示例3: execute

 /**
  * Execute this console command
  *
  * @param  InputInterface  $input  Command line input interface
  * @param  OutputInterface $output Command line output interface
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $dropTables = $input->getOption('drop-tables');
     if (!$this->hasTablesOrViews() || $dropTables) {
         if ($dropTables && $this->appEnv === 'production') {
             $output->writeln('Cannot drop tables when app environment is production.');
             return;
         }
         // Console message heading padded by a newline
         $output->write(['', '  -- APP INSTALL --', ''], true);
         $output->write(['  Dropping tables', ''], true);
         $this->dropViews();
         $this->dropTables();
         try {
             $installScript = $this->getInstallScript();
         } catch (RuntimeException $e) {
             $output->writeln($e->getMessage());
             return;
         }
         $this->install($installScript, $output);
     }
     // Run all migrations
     $output->writeln('  Executing new migrations');
     $this->runMigrationsCommand->run(new ArrayInput(['migrations:run']), $output);
     $output->write(['  Done!', ''], true);
 }
开发者ID:bodetree,项目名称:synapse-base,代码行数:32,代码来源:RunInstallCommand.php

示例4: runCommand

 /**
  * Run given command and return its output.
  *
  * @param Command $command
  * @param array $input
  * @return string
  */
 protected function runCommand(Command $command, array $input = [])
 {
     $stream = fopen("php://memory", "r+");
     $input = new ArrayInput($input);
     $command->run($input, new StreamOutput($stream));
     rewind($stream);
     return stream_get_contents($stream);
 }
开发者ID:bound1ess,项目名称:adviser,代码行数:15,代码来源:CommandTestCase.php

示例5: executeCommand

 private function executeCommand(Command $command, Input $input)
 {
     $command->setApplication($this->application);
     $input->setInteractive(false);
     if ($command instanceof ContainerAwareCommand) {
         $command->setContainer($this->client->getContainer());
     }
     $command->run($input, new NullOutput());
 }
开发者ID:ajouve,项目名称:doctrine-fixtures-test,代码行数:9,代码来源:FixtureTestCase.php

示例6: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     try {
         return parent::run($input, $output);
     } catch (\Exception $e) {
         if ($input->getOption('alert')) {
             mtrace($e, "Exception while running command " . $this->getName(), 'alert');
         }
         throw $e;
     }
 }
开发者ID:oasmobile,项目名称:php-slimapp,代码行数:11,代码来源:AbstractAlertableCommand.php

示例7: run

 /**
  * Override run to let Exceptions function as exit codes.
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     try {
         return parent::run($input, $output);
     } catch (Exception $e) {
         $output->writeln("<error>" . $e->getMessage() . "</error>");
         return $e->getCode() > 0 ? $e->getCode() : 1;
     }
 }
开发者ID:xendk,项目名称:proctor,代码行数:14,代码来源:ProctorCommand.php

示例8: executeCommand

 protected static function executeCommand(Command $command, $siteDir)
 {
     if (!is_dir($siteDir)) {
         throw new \RuntimeException('The meinhof-site-dir (' . $siteDir . ') specified in composer.json was not found in ' . getcwd());
     }
     $helpers = new HelperSet(array(new FormatterHelper(), new DialogHelper()));
     $command->setHelperSet($helpers);
     $input = new ArrayInput(array('dir' => $siteDir));
     $output = new ConsoleOutput();
     $command->run($input, $output);
 }
开发者ID:miguelibero,项目名称:meinhof,代码行数:11,代码来源:ScriptHandler.php

示例9: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     $this->depedencies = $this->getApplication()->getKernel()->getContainer()->get('mardraze_core.depedencies');
     $context = $this->depedencies->get('router')->getContext();
     $mainHost = $this->depedencies->getParameter('mardraze_http_host');
     $host = preg_replace('/http(s)?:\\/\\//', '', $mainHost);
     $scheme = strpos($mainHost, 'https:') === false ? 'http' : 'https';
     $context->setHost($host);
     $context->setScheme($scheme);
     $this->input = $input;
     $this->output = $output;
     return parent::run($input, $output);
 }
开发者ID:mardraze,项目名称:core-bundle,代码行数:13,代码来源:MardrazeBaseCommand.php

示例10: run

 /**
  * {@inheritdoc}
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // Store the input and output for easier usage
     $this->input = $input;
     if (!$output instanceof Output) {
         throw new \InvalidArgumentException('Not the expected output type');
     }
     $this->output = $output;
     $dialogHelper = class_exists('Symfony\\Component\\Console\\Helper\\QuestionHelper') ? $this->getHelperSet()->get('question') : $this->getHelperSet()->get('dialog');
     $this->output->setDialogHelper($dialogHelper);
     $this->output->setFormatterHelper($this->getHelperSet()->get('formatter'));
     Context::getInstance()->setService('input', $this->input);
     Context::getInstance()->setService('output', $this->output);
     parent::run($input, $output);
 }
开发者ID:liip,项目名称:rmt,代码行数:18,代码来源:BaseCommand.php

示例11: run

 /**
  * Runs the command.
  *
  * Before the decorated command is run, a lock is requested.
  * When failed to acquire the lock, the command exits.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return int The command exit code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     $this->mergeApplicationDefinition();
     $input->bind($this->getDefinition());
     $lock = $this->getLockHandler($input);
     if (!$lock->lock()) {
         $this->writeLockedMessage($input, $output);
         return 1;
     }
     try {
         return $this->decoratedCommand->run($input, $output);
     } finally {
         $lock->release();
     }
 }
开发者ID:frankdejonge,项目名称:locked-console-command,代码行数:26,代码来源:LockedCommandDecorator.php

示例12: run

    public function run(InputInterface $input, OutputInterface $output)
    {
        try {
            return parent::run($input, $output);
        } catch (RuntimeException $e) {
            if ($e->getMessage() === 'invalid token') {
                throw new AuthException(<<<TEXT
Your authentication token is invalid or has not been set yet.
Execute 'trello config generate' and follow the instructions.
TEXT
);
            } else {
                throw $e;
            }
        }
    }
开发者ID:svenax,项目名称:trello-cli,代码行数:16,代码来源:CommandBase.php

示例13: run

 /**
  * @see Symfony\Component\Console\Command\Command::run()
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // Force the creation of the synopsis before the merge with the app definition
     $this->getSynopsis();
     // Merge our options
     $this->addOption('run-once', null, InputOption::VALUE_NONE, 'Run the command just once, do not go into an endless loop');
     $this->addOption('detect-leaks', null, InputOption::VALUE_NONE, 'Output information about memory usage');
     // Add the signal handler
     if (function_exists('pcntl_signal')) {
         // Enable ticks for fast signal processing
         declare (ticks=1);
         pcntl_signal(SIGTERM, array($this, 'handleSignal'));
         pcntl_signal(SIGINT, array($this, 'handleSignal'));
     }
     // And now run the command
     return parent::run($input, $output);
 }
开发者ID:famouscake,项目名称:daemonizable-command,代码行数:20,代码来源:EndlessCommand.php

示例14: execute

 public function execute(Command $command, array $input, array $options = array())
 {
     // set the command name automatically if the application requires
     // this argument and no command name was passed
     if (!isset($input['command']) && null !== ($application = $this->command->getApplication()) && $application->getDefinition()->hasArgument('command')) {
         $input = array_merge(array('command' => $this->command->getName()), $input);
     }
     $this->input = new ArrayInput($input);
     if (isset($options['interactive'])) {
         $this->input->setInteractive($options['interactive']);
     }
     $this->output = new StreamOutput(fopen('php://memory', 'w', false));
     if (isset($options['decorated'])) {
         $this->output->setDecorated($options['decorated']);
     }
     if (isset($options['verbosity'])) {
         $this->output->setVerbosity($options['verbosity']);
     }
     return $this->statusCode = $command->run($this->input, $this->output);
 }
开发者ID:kodazzi,项目名称:framework,代码行数:20,代码来源:Shell.php

示例15: run

 public function run(InputInterface $input, OutputInterface $output)
 {
     // check if the php pcntl_signal functions are accessible
     $this->php_pcntl_signal = function_exists('pcntl_signal');
     if ($this->php_pcntl_signal) {
         // Collect interrupts and notify the running command
         pcntl_signal(SIGTERM, [$this, 'cancelOperation']);
         pcntl_signal(SIGINT, [$this, 'cancelOperation']);
     }
     return parent::run($input, $output);
 }
开发者ID:ZverAleksey,项目名称:core,代码行数:11,代码来源:base.php


注:本文中的Symfony\Component\Console\Command\Command::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。