本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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'));
}
示例12: run
/**
* {@inheritDoc}
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
if (null === $output) {
$output = Factory::createOutput();
}
return parent::run($input, $output);
}
示例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;
}
示例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();
}
示例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());
}