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


PHP Application::run方法代碼示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 public function execute(ContainerInterface $app)
 {
     foreach ($this->commands as $command) {
         $this->console->add($app->create($command));
     }
     $this->console->run();
 }
開發者ID:Festiv,項目名稱:Festiv,代碼行數:10,代碼來源:ConsoleKernel.php

示例2: start

 protected function start()
 {
     $this->console = new SymfonyApplication(self::APP_NAME, self::VERSION);
     foreach ($this->commands as $command) {
         $this->console->add($command);
     }
     $this->console->run();
 }
開發者ID:titaphp,項目名稱:framework,代碼行數:8,代碼來源:Application.php

示例3: run

 /**
  * @throws \Exception
  */
 public function run()
 {
     $commands = $this->config('commands');
     foreach ($commands as $command) {
         $this->console->add($this->container->get($command));
     }
     $this->console->run();
 }
開發者ID:dafiti,項目名稱:kong-cli,代碼行數:11,代碼來源:Application.php

示例4: run

 /**
  * @param string $input
  *
  * @return integer
  */
 public function run($input)
 {
     $this->input = new StringInput($input);
     $this->output = new StreamOutput(fopen('php://memory', 'w', false));
     $inputStream = $this->getInputStream();
     rewind($inputStream);
     $this->application->getHelperSet()->get('dialog')->setInputStream($inputStream);
     $this->result = $this->application->run($this->input, $this->output);
 }
開發者ID:coduo,項目名稱:phpspec-matcher-extension,代碼行數:14,代碼來源:ApplicationTester.php

示例5: cliAction

 /**
  * Index action - runs the console application
  */
 public function cliAction()
 {
     $exitCode = $this->cliApplication->run(new RequestInput($this->getRequest()));
     if (is_numeric($exitCode)) {
         $model = class_exists(ViewModel::class) ? new ViewModel() : new V2ViewModel();
         $model->setErrorLevel($exitCode);
         return $model;
     }
 }
開發者ID:TomHAnderson,項目名稱:DoctrineModule,代碼行數:12,代碼來源:CliController.php

示例6: runAction

 /**
  * 
  * @return ConsoleModel
  */
 public function runAction()
 {
     $exitCode = $this->application->run(new RequestInput($this->getRequest()));
     if (is_numeric($exitCode)) {
         $model = new ConsoleModel();
         $model->setErrorLevel($exitCode);
         return $model;
     }
 }
開發者ID:alex-oleshkevich,項目名稱:zf-extras,代碼行數:13,代碼來源:ConsoleController.php

示例7: run

 public function run()
 {
     if ($this->container->getConfig()->get('app.debug')) {
         foreach ($this->app->all() as $commandKey => $command) {
             if (method_exists($command, 'isVagrant') && $command->isVagrant()) {
                 $this->toggleVagrantCommand($commandKey, $command);
             }
         }
     }
     $this->app->run();
 }
開發者ID:sinergi,項目名稱:core,代碼行數:11,代碼來源:CommandRuntime.php

示例8: execute

 /**
  * Main function of Facilior
  * @return int
  */
 public function execute()
 {
     //Greetings
     $this->console->log('Logging started');
     $this->console->output('<fg=default;options=bold>Logging started:</> <fg=magenta>' . $this->console->getLogFile() . '</>', 0, 2);
     $fileService = new FileService();
     $fileService->init();
     //Run Command and check if there is a config error
     $exitCode = $this->application->run();
     $fileService->cleanup();
     return $exitCode;
 }
開發者ID:lotzer,項目名稱:facilior,代碼行數:16,代碼來源:Console.php

示例9: runCommand

 /**
  * {@inheritdoc}
  */
 public function runCommand($command, $params = [])
 {
     $params = array_merge(['command' => $command], $params, $this->getDefaultParams());
     $this->application->setAutoExit(false);
     $exitCode = $this->application->run(new ArrayInput($params), $this->output);
     if (0 !== $exitCode) {
         $this->application->setAutoExit(true);
         $errorMessage = sprintf('The command terminated with an error code: %u.', $exitCode);
         $this->output->writeln("<error>{$errorMessage}</error>");
         $e = new \Exception($errorMessage, $exitCode);
         throw $e;
     }
     return $this;
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:17,代碼來源:CommandExecutor.php

示例10: runCommand

 /**
  * @param $command
  * @param array $parameters
  * @param OutputInterface $output
  *
  * @return $this
  *
  * @throws \Exception
  */
 public function runCommand($command, $parameters = array(), OutputInterface $output = null)
 {
     $parameters = array_merge(array('command' => $command), $this->getDefaultParameters(), $parameters);
     $this->application->setAutoExit(false);
     $exitCode = $this->application->run(new ArrayInput($parameters), $output ?: new NullOutput());
     if (0 !== $exitCode) {
         $this->application->setAutoExit(true);
         $errorMessage = sprintf('The command terminated with an error code: %u.', $exitCode);
         $this->output->writeln("<error>{$errorMessage}</error>");
         $exception = new \Exception($errorMessage, $exitCode);
         throw $exception;
     }
     return $this;
 }
開發者ID:Strontium-90,項目名稱:Sylius,代碼行數:23,代碼來源:CommandExecutor.php

示例11: testCommand

 public function testCommand()
 {
     $app = new Application('Propel', Propel::VERSION);
     $command = new DatabaseReverseCommand();
     $app->add($command);
     $currentDir = getcwd();
     $outputDir = __DIR__ . '/../../../../reversecommand';
     chdir(__DIR__ . '/../../../../Fixtures/bookstore');
     $input = new \Symfony\Component\Console\Input\ArrayInput(array('command' => 'database:reverse', '--database-name' => 'reverse-test', '--output-dir' => $outputDir, '--verbose' => true, '--platform' => ucfirst($this->getDriver()) . 'Platform', 'connection' => $this->getConnectionDsn('bookstore-schemas', true)));
     $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+'));
     $app->setAutoExit(false);
     $result = $app->run($input, $output);
     chdir($currentDir);
     if (0 !== $result) {
         rewind($output->getStream());
         echo stream_get_contents($output->getStream());
     }
     $this->assertEquals(0, $result, 'database:reverse tests exited successfully');
     $databaseXml = simplexml_load_file($outputDir . '/schema.xml');
     $this->assertEquals('reverse-test', $databaseXml['name']);
     $this->assertGreaterThan(20, $databaseXml->xpath("table"));
     $table = $databaseXml->xpath("table[@name='acct_access_role']");
     $this->assertCount(1, $table);
     $table = $table[0];
     $this->assertEquals('acct_access_role', $table['name']);
     $this->assertEquals('AcctAccessRole', $table['phpName']);
     $this->assertCount(2, $table->xpath('column'));
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:28,代碼來源:DatabaseReverseTest.php

示例12: run

 /**
  * {@inheritDoc}
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $output) {
         $output = Factory::createOutput();
     }
     return parent::run($input, $output);
 }
開發者ID:detain,項目名稱:composer,代碼行數:10,代碼來源:Application.php

示例13: run

 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     $fp = fopen($this->config['lockfile'], "w");
     // if you run this script as root - change user/group
     if (file_exists($this->config['lockfile'])) {
         chown($this->config['lockfile'], $this->config['file-user']);
         chgrp($this->config['lockfile'], $this->config['file-group']);
     }
     $exitCode = 0;
     if (flock($fp, LOCK_EX | LOCK_NB)) {
         // acquire an exclusive lock
         ftruncate($fp, 0);
         $exitCode = parent::run($input, $output);
         fflush($fp);
         // flush output before releasing the lock
         flock($fp, LOCK_UN);
         // release the lock
     } else {
         //throw new DNSSyncException("Running multiple instances is not allowed."); - nezachytí applikace error
         //$output->writeln() - null v této chvíli
         $message = "Running multiple instances is not allowed.";
         echo $message . PHP_EOL;
         mail($this->config['admin-email'], $message, $message);
         $exitCode = 500;
     }
     fclose($fp);
     return $exitCode;
 }
開發者ID:heximcz,項目名稱:synknot,代碼行數:28,代碼來源:DNSSyncApplication.php

示例14: run

 /**
  * Inicializa a aplicação.
  *
  * @throws \Exception
  */
 public function run()
 {
     //apenas para inicializar
     Config::getInstance();
     $application = new Application();
     $commands = [];
     /* Carregando os comandos internos */
     $anna_commands = __DIR__ . DS . 'Commands' . DS;
     $anna_commands = $this->loadAppCommands($anna_commands);
     /* Carregandos os comandos criados pelos desenvolvedores */
     $app_commands = SYS_ROOT . 'App' . DS . 'Console' . DS;
     $app_commands = $this->loadAppCommands($app_commands);
     /* Registra todos os comandos encontrados */
     foreach ($app_commands as $cmd) {
         $commands[] = new $cmd();
     }
     foreach ($anna_commands as $cmd) {
         $class = new \ReflectionClass($cmd);
         if (!$class->isAbstract()) {
             $commands[] = new $cmd();
         }
     }
     $application->addCommands($commands);
     $application->run();
 }
開發者ID:anna-framework,項目名稱:anna,代碼行數:30,代碼來源:Initializer.php

示例15: run

 /**
  * @param InputInterface|null $input
  * @param OutputInterface|null $output
  * @return int
  * @throws \Exception
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     foreach ($this->factory->createCommands() as $command) {
         $this->add($command);
     }
     return parent::run($input, $this->factory->createOutput());
 }
開發者ID:TYPO3,項目名稱:Surf,代碼行數:13,代碼來源:ConsoleApplication.php


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