本文整理汇总了PHP中Symfony\Component\Console\Application::setAutoExit方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::setAutoExit方法的具体用法?PHP Application::setAutoExit怎么用?PHP Application::setAutoExit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Application
的用法示例。
在下文中一共展示了Application::setAutoExit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$_SERVER['PHWOOLCON_MIGRATION_PATH'] = TEST_ROOT_PATH . '/bin/migrations';
$this->cli = Cli::register($this->di);
$this->cli->setAutoExit(false);
$this->output = new BufferedOutput();
}
示例2: __construct
/**
* Services constructor.
*/
public function __construct()
{
$this->kernel = new Kernel();
$this->application = new Application('Neusta Facilior', FACILIOR_VERSION);
$this->application->setAutoExit(false);
//Creates Services Output
$this->console = new ConsoleService();
//Loads Commands into Application
$this->application->addCommands($this->kernel->commands());
}
示例3: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->app = new Application();
$this->app->setAutoExit(false);
$this->app->add(new GenerateKeyCommand());
$this->filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . '/test.key';
if (file_exists($this->filename)) {
unlink($this->filename);
}
}
示例4: 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;
}
示例5: 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;
}
示例6: main
/**
* command应用主入口
* @throws \Exception
*/
static function main()
{
$application = new Application();
$application->setAutoExit(true);
$application->addCommands(self::createCommands());
$application->run();
}
示例7: run
/**
* @param null $input Input
* @return int|void
* @throws \Exception
*
* Run tg and return an error code
*/
public function run($input = null)
{
register_shutdown_function([$this, 'shutdown']);
set_error_handler([$this, 'handleError']);
if ($this->classCache->getCachePath() === null) {
$this->classCache->setCachePath(__DIR__ . "/../.tg/");
}
$hasCommandFile = $this->autoloadCommandFile();
$this->setupDevModes();
$this->input = $this->prepareInput($input ? $input : $_SERVER['argv']);
//Load all our commands
$commandLoader = new CommandLoader();
$this->loadLocalFile($commandLoader, $hasCommandFile);
//Cwd project specific
$this->loadCoreCommands($commandLoader);
//Tg vendor and core
if (!$this->coreDevMode) {
//If we are developing in the core we dont want to load cwd vendors folder at all
$this->loadLocalVendors($commandLoader);
//Cwd vendor
}
if ($this->libDevMode) {
//If we are developing a library we want to load the cwd source folder
$this->loadLocalSrc($commandLoader);
}
//Set up the robo static config class :(
Config::setInput($this->input);
Config::setOutput($this->output);
$this->app->setAutoExit(false);
return $this->app->run($this->input, $this->output);
}
示例8: executeCommand
protected function executeCommand($command)
{
// Cache can not be warmed up as classes can not be redefined during one request
if (preg_match('/^cache:clear/', $command)) {
$command .= ' --no-warmup';
}
$input = new StringInput($command);
$input->setInteractive(false);
$output = new StringOutput();
$formatter = $output->getFormatter();
$formatter->setDecorated(true);
$output->setFormatter(new HtmlOutputFormatterDecorator($formatter));
# MVC object store
MVCStore::store('mvc', $this->mvc);
// Some commands (i.e. doctrine:query:dql) dump things out instead of returning a value
ob_start();
$this->application->setAutoExit(false);
$errorCode = $this->application->run($input, $output);
// So, if the returned output is empty
if (!($result = $output->getBuffer())) {
$result = ob_get_contents();
// We replace it by the catched output
}
ob_end_clean();
return array('command' => $command, 'output' => $result, 'errorCode' => $errorCode);
}
示例9: 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'));
}
示例10: initializeConsoleApplication
private static function initializeConsoleApplication()
{
$app = self::$app;
$console = new ConsoleApplication('Booothy test console runner');
$console->setAutoExit(false);
require 'src/App/Ui/Silex/Console/Command/App/CreateUser.php';
self::$console = $console;
}
示例11:
/**
* ConsoleApplication constructor.
*
* ><p>**Note:** you'll have to configure the IO channels (ex. calling {@see setupStandardIO}) before running the
* application.
*
* @param ConsoleIO $io
* @param ConsoleSettings $settings
* @param SymfonyConsole $console
* @param InjectorInterface $injector
*/
function __construct(ConsoleIO $io, ConsoleSettings $settings, SymfonyConsole $console, InjectorInterface $injector)
{
$this->io = $io;
$this->console = $console;
$this->injector = $injector;
$this->settings = $settings;
$console->setAutoExit(false);
$io->terminalSize($console->getTerminalDimensions());
}
示例12: runTest
public function runTest()
{
$application = new Application();
$application->setAutoExit(false);
$application->add(new GreetCommand());
$application->add(new AllCommand());
$this->testCommand();
$application->run();
}
示例13: run
/**
* Runs console with the given helperset.
*
* @param \Symfony\Component\Console\Helper\HelperSet $helperSet
* @param \Symfony\Component\Console\Command\Command[] $commands
*
* @return void
*/
public static function run(HelperSet $helperSet, $commands = array(), OutputInterface $output = null)
{
$cli = new Application('Doctrine Command Line Interface', Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->setAutoExit(false);
$commands = array_merge(self::getDefaultCommands(), $commands);
$cli->addCommands($commands);
$cli->run(null, $output);
}
示例14: runTest
public function runTest()
{
$dispatcher = $this->dispatcher = new EventDispatcher();
$application = new Application();
$application->setAutoExit(false);
$application->setDispatcher($dispatcher);
$this->testOne();
$this->testTwo();
$application->run();
}
示例15: runCommand
/**
* Launches a command.
* If '--process-isolation' parameter is specified the command will be launched as a separate process.
* In this case you can parameter '--process-timeout' to set the process timeout
* in seconds. Default timeout is 60 seconds.
* If '--ignore-errors' parameter is specified any errors are ignored;
* otherwise, an exception is raises if an error happened.
*
* @param string $command
* @param array $params
* @return CommandExecutor
* @throws \RuntimeException if command failed and '--ignore-errors' parameter is not specified
*/
public function runCommand($command, $params = array())
{
$params = array_merge(array('command' => $command, '--no-debug' => true), $params);
if ($this->env && $this->env !== 'dev') {
$params['--env'] = $this->env;
}
$ignoreErrors = false;
if (array_key_exists('--ignore-errors', $params)) {
$ignoreErrors = true;
unset($params['--ignore-errors']);
}
if (array_key_exists('--process-isolation', $params)) {
unset($params['--process-isolation']);
$phpFinder = new PhpExecutableFinder();
$php = $phpFinder->find();
$pb = new ProcessBuilder();
$pb->add($php)->add($_SERVER['argv'][0]);
if (array_key_exists('--process-timeout', $params)) {
$pb->setTimeout($params['--process-timeout']);
unset($params['--process-timeout']);
}
foreach ($params as $param => $val) {
if ($param && '-' === $param[0]) {
if ($val === true) {
$pb->add($param);
} elseif (is_array($val)) {
foreach ($val as $value) {
$pb->add($param . '=' . $value);
}
} else {
$pb->add($param . '=' . $val);
}
} else {
$pb->add($val);
}
}
$process = $pb->inheritEnvironmentVariables(true)->getProcess();
$output = $this->output;
$process->run(function ($type, $data) use($output) {
$output->write($data);
});
$ret = $process->getExitCode();
} else {
$this->application->setAutoExit(false);
$ret = $this->application->run(new ArrayInput($params), $this->output);
}
if (0 !== $ret) {
if ($ignoreErrors) {
$this->output->writeln(sprintf('<error>The command terminated with an error code: %u.</error>', $ret));
} else {
throw new \RuntimeException(sprintf('The command terminated with an error status: %u.', $ret));
}
}
return $this;
}