本文整理汇总了PHP中Symfony\Component\Console\Application::setDefaultCommand方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::setDefaultCommand方法的具体用法?PHP Application::setDefaultCommand怎么用?PHP Application::setDefaultCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Application
的用法示例。
在下文中一共展示了Application::setDefaultCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* @return Application
*/
public function create()
{
$app = new Application(Message::NAME, Message::VERSION);
$app->setDefaultCommand(Message::COMMAND);
$app->add($this->createAnalyzeCommand());
return $app;
}
示例2: __construct
/**
* Constructor
*/
public function __construct($applicationDir)
{
// Init console application
$this->consoleApplication = new ConsoleApplication();
// Adding commands
$commandNotificationSendCommand = new NotificationSendCommand($applicationDir);
$this->consoleApplication->add($commandNotificationSendCommand);
$this->consoleApplication->setDefaultCommand($commandNotificationSendCommand->getName());
}
示例3: main
/**
* command应用主入口
* @throws \Exception
*/
static function main()
{
$application = new Application();
$application->addCommands(self::createCommands());
$application->setDefaultCommand(ThumbnailCommand::COMMAND_NAME);
$application->run();
}
示例4: main
/**
* command应用主入口
* @throws \Exception
*/
static function main()
{
$application = new Application();
$application->addCommands(self::createCommands());
$application->setDefaultCommand(self::DEFAULT_COMMAND_NAME);
$application->run();
}
示例5: getApp
function getApp() : Application
{
$app = new Application();
$app->add(new TestCommand());
$app->setDefaultCommand('test');
return $app;
}
示例6: execute
public function execute()
{
$console = new Application('');
$def = new ListCommand();
$console->add($def);
$console->setDefaultCommand($def->getName());
foreach ($this->path as $path) {
$files = (new FileHandler($path))->readDir();
foreach ($files as $file) {
$command = basename($file, '.php');
if ('BaseCommand' === $command) {
continue;
}
$console->add($this->fetchCommand($command));
}
}
$output = new ConsoleOutput();
self::warningText($output);
self::errorText($output);
$console->run(null, $output);
}
示例7: run
public function run()
{
$console = new Application(self::APP_NAME, self::APP_VERSION);
$console->setDefaultCommand(self::APP_DEFAULT_COMMAND);
$dispatcher = new EventDispatcher();
$dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
// get the input instance
// $input = $event->getInput();
// get the output instance
$output = $event->getOutput();
// get the command to be executed
$command = $event->getCommand();
// write something about the command
//$output->writeln(sprintf('Before running command <info>%s</info>', $command->getName()));
if ($command->getName() == StartServer::CLI_COMMAND) {
$output->write(self::$BANNER);
}
// get the application
// $application = $command->getApplication();
});
$console->setDispatcher($dispatcher);
$console->addCommands([new Controller\StartServer(), new Controller\StopServer(), new Controller\ListServers(), new Controller\RegisterServer()]);
$console->run();
}
示例8: Application
#!/usr/bin/env php
<?php
/*
* This file is part of the Certificationy CLI application.
*
* (c) Vincent Composieux <vincent.composieux@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require __DIR__ . '/vendor/autoload.php';
use Certificationy\Cli\Command\StartCommand;
use KevinGH\Amend\Command;
use KevinGH\Amend\Helper;
use Symfony\Component\Console\Application;
use Symfony\Component\Yaml\Yaml;
const VERSION = 1.4;
const APPLICATION_NAME = 'Certificationy';
$application = new Application(APPLICATION_NAME, VERSION);
$config = Yaml::parse(file_get_contents('config.yml'));
$updateCommand = new Command('self-update');
$updateCommand->setManifestUri($config['manifest_uri']);
$application->add($updateCommand);
$application->getHelperSet()->set(new Helper());
$startCommand = new StartCommand();
$application->add($startCommand);
$application->setDefaultCommand($startCommand->getName());
$application->run();
示例9: Application
<?php
require_once __DIR__ . "/../vendor/autoload.php";
use Symfony\Component\Console\Application;
use jamesiarmes\PEWS\Generator\ConvertToPHP;
error_reporting(error_reporting() & ~E_NOTICE);
$cli = new Application('Convert XSD to PHP classes Command Line Interface', "2.0");
$cli->setCatchExceptions(true);
$cli->setDefaultCommand('convert:php');
$cli->addCommands(array(new ConvertToPHP()));
$cli->run();
示例10: die
<?php
require __DIR__ . '/vendor/autoload.php';
use SensioLabs\Deptrac\CompilerPass\CollectorPass;
use SensioLabs\Deptrac\CompilerPass\OutputFormatterPass;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
if (!version_compare(phpversion(), "5.5.9", '>=')) {
echo 'Required at least PHP version 5.5.9, your version: ' . PHP_VERSION . "\n";
die(1);
}
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator(__DIR__)))->load(__DIR__ . '/services.xml');
$container->addCompilerPass(new OutputFormatterPass())->addCompilerPass(new CollectorPass())->compile();
$container->set('container', $container);
$application = new Application();
$application->add($container->get('command_init'));
$application->add($container->get('command_analyze'));
$application->add($container->get('command_self_update'));
$application->setDefaultCommand('analyze');
$application->run();
示例11: fwrite
#!/usr/bin/env php
<?php
if (version_compare(phpversion(), '5.4', '<')) {
fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.4\n");
exit(1);
}
Phar::mapPhar('distill-cli.phar');
require_once 'phar://distill-cli.phar/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Distill\Cli\Command as DistillCommand;
$appVersion = '1.0.4';
$app = new Application('Distill CLI', $appVersion);
$app->add(new DistillCommand\ExtractCommand($appVersion));
$app->add(new DistillCommand\AboutCommand($appVersion));
$app->add(new DistillCommand\SelfUpdateCommand($appVersion));
$app->setDefaultCommand('about');
$app->run();
__halt_compiler();
示例12: Application
Debug::enable(E_ALL, true);
$container = \DG\App\loadContainer();
$eventDispatcher = $container->get('event_dispatcher.traceable');
$app = new Application();
$app->add(new MakesCacheCommand($container));
$app->add(new CssSelectorTestCommand());
$app->add($reportCommand = new MakesCacheReportCommand());
$app->add(new DomCrawlerTestCommand());
$app->add(new DomCrawlerHHTestCommand());
$app->add(new ExpressionLanguageCommand());
$app->add(new LockHandlerTestCommand());
$app->add(new IntlTestCommand());
$app->add(new ModelsCommand($container));
$app->add(new ProcessCommand());
$app->add(new TestTimingAttackCommand());
$app->setDefaultCommand($reportCommand->getName());
$app->setDispatcher($eventDispatcher);
$eventDispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) use($reportCommand) {
$output = $event->getOutput();
$output->writeln("<info>Run command " . $event->getCommand()->getName() . "</info>");
if ($event->getCommand() instanceof MakesCacheReportCommand) {
$finder = new Finder();
$makesCacheFilesCount = $finder->in(CACHE_PATH)->name('makes*.json')->count();
if ($makesCacheFilesCount === 0 && $event->getCommand()->getName() === $reportCommand->getName()) {
$output->writeln("<error>There is no cache files. Command execution stopped</error>");
$event->disableCommand();
}
}
});
$eventDispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
//wrap exception
示例13:
#!/usr/bin/php
<?php
// Require composer autoloader
require_once __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console;
// Create twitter service
$dataStore = new Ornithology\Service\DataStoreFile(getenv('HOME') . '/.ornithology');
$twitterService = new Ornithology\Service\Twitter($dataStore);
// Initialize the application
$application = new Console\Application('Ornithology', '0.0.3');
// Add application related commands
$application->add(new Ornithology\Command\Quit('exit'));
$application->add(new Ornithology\Command\Mark('mark'));
// Add twitter related commands
$application->add(new Ornithology\Command\Authorize('authorize', $twitterService));
$application->add(new Ornithology\Command\Refresh('refresh', $twitterService));
$application->add(new Ornithology\Command\Tweet('tweet', $twitterService));
$application->add(new Ornithology\Command\Reply('reply', $twitterService));
$application->add(new Ornithology\Command\Retweet('retweet', $twitterService));
$application->add(new Ornithology\Command\Favorite('favorite', $twitterService));
$application->add(new Ornithology\Command\Urls('urls', $twitterService));
// Set some defaults
$application->setDefaultCommand('mark');
// Run the application as a shell
$shell = new Console\Shell($application);
$shell->run();
示例14: Application
<?php
/**
* Created by Érick Carvalho on 17/12/2015.
*/
require 'vendor/autoload.php';
use Symfony\Component\Console\Application;
use WordFilter\Console\Commands\MainMenuCommand;
use WordFilter\Console\Commands\CorrectorCommand;
use WordFilter\Console\Commands\DictionaryManagerCommand;
$application = new Application('Word Filter', '1.0.1');
$application->add(new DictionaryManagerCommand());
$application->add(new CorrectorCommand());
$application->add(new MainMenuCommand());
$application->setDefaultCommand('menu');
$application->run();
示例15: Application
#!/usr/bin/env php
<?php
require_once './libraries/autoload.php';
use DedicatedManager\Setup\SetupCommand;
use Symfony\Component\Console\Application;
error_reporting(E_ALL & ~E_DEPRECATED & ~E_WARNING);
$application = new Application();
$application->add(new SetupCommand());
$application->setDefaultCommand('setup');
$application->run();