本文整理汇总了PHP中Symfony\Component\Console\Style\SymfonyStyle类的典型用法代码示例。如果您正苦于以下问题:PHP SymfonyStyle类的具体用法?PHP SymfonyStyle怎么用?PHP SymfonyStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SymfonyStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->title('Check Pre-commit requirements');
$hasError = false;
$resultOkVal = '<fg=green>✔</>';
$resultNokVal = '<fg=red>✘</>';
$commands = ['Composer' => array('command' => 'composer', 'result' => $resultOkVal), 'xmllint' => array('command' => 'xmllint', 'result' => $resultOkVal), 'jsonlint' => array('command' => 'jsonlint', 'result' => $resultOkVal), 'eslint' => array('command' => 'eslint', 'result' => $resultOkVal), 'sass-convert' => array('command' => 'sass-convert', 'result' => $resultOkVal), 'scss-lint' => array('command' => 'scss-lint', 'result' => $resultOkVal), 'phpcpd' => array('command' => 'phpcpd', 'result' => $resultOkVal), 'php-cs-fixer' => array('command' => 'php-cs-fixer', 'result' => $resultOkVal), 'phpmd' => array('command' => 'phpmd', 'result' => $resultOkVal), 'phpcs' => array('command' => 'phpcs', 'result' => $resultOkVal), 'box' => array('command' => 'box', 'result' => $resultOkVal)];
foreach ($commands as $label => $command) {
if (!$this->checkCommand($label, $command['command'])) {
$commands[$label]['result'] = $resultNokVal;
$hasError = true;
}
}
// Check Php conf param phar.readonly
if (!ini_get('phar.readonly')) {
$commands['phar.readonly'] = array('result' => $resultOkVal);
} else {
$commands['phar.readonly'] = array('result' => 'not OK (set "phar.readonly = Off" on your php.ini)');
}
$headers = ['Command', 'check'];
$rows = [];
foreach ($commands as $label => $cmd) {
$rows[] = [$label, $cmd['result']];
}
$io->table($headers, $rows);
if (!$hasError) {
$io->success('All Requirements are OK');
} else {
$io->note('Please fix all requirements');
}
exit(0);
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$name = str_replace('/', '\\', $input->getArgument('name'));
$this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
$this->cache->purge();
if (!in_array($name, $this->load_migrations())) {
$io->error($this->language->lang('MIGRATION_NOT_VALID', $name));
return 1;
} else {
if ($this->migrator->migration_state($name) === false) {
$io->error($this->language->lang('MIGRATION_NOT_INSTALLED', $name));
return 1;
}
}
try {
while ($this->migrator->migration_state($name) !== false) {
$this->migrator->revert($name);
}
} catch (\phpbb\db\migration\exception $e) {
$io->error($e->getLocalisedMessage($this->user));
$this->finalise_update();
return 1;
}
$this->finalise_update();
$io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
}
示例3: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->comment("Warming up the cache (<info>{$this->cacheDir}</info>)");
$this->cacheWarmer->warmup($this->cacheDir);
$io->success('Cache warmed up');
}
示例4: execute
public function execute(SymfonyStyle $io = null)
{
$currentProfiles = $this->em->getRepository('CampaignChainLocationGoogleAnalyticsBundle:Profile')->findAll();
if (empty($currentProfiles)) {
$io->text('There is no Profile entity to update');
return true;
}
foreach ($currentProfiles as $profile) {
if (substr($profile->getProfileId(), 0, 2) != 'UA') {
continue;
}
$profile->setPropertyId($profile->getProfileId());
$gaProfileUrl = $profile->getLocation()->getUrl();
$google_base_url = 'https:\\/\\/www.google.com\\/analytics\\/web\\/#report\\/visitors-overview\\/a' . $profile->getAccountId() . 'w\\d+p';
$pattern = '/' . $google_base_url . '(.*)/';
preg_match($pattern, $gaProfileUrl, $matches);
if (!empty($matches) && count($matches) == 2) {
$profile->setProfileId($matches[1]);
$profile->setIdentifier($profile->getProfileId());
}
$this->em->persist($profile);
}
$this->em->flush();
return true;
}
示例5: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->getFormatter()->setStyle('red', new OutputFormatterStyle('red', 'default'));
$header = ['Show', 'Episode Title', 'Season/Episode', 'Date', 'Link'];
$this->displayAsTable($io, $header, $this->getUpcomingEpisodes());
}
示例6: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$outputStyle = new SymfonyStyle($input, $output);
$outputStyle->title('Displaying current configuration for currency exchange bundle');
$this->displaySources($outputStyle)->displayNewLine($outputStyle)->displayProcessors($outputStyle)->displayNewLine($outputStyle)->displayRepository($outputStyle)->displayNewLine($outputStyle)->displayRates($outputStyle)->displayNewLine($outputStyle);
$outputStyle->success('Configuration is valid.');
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$fileInput = trim($input->getArgument('file'));
$pathInfoFile = pathinfo(realpath($fileInput));
$file = new File('', realpath($fileInput), $pathInfoFile['dirname']);
$fileCollection = new FileCollection();
$fileCollection = $fileCollection->append($file);
$reporter = new Reporter($output, 1);
$review = new StaticReview($reporter);
$review->addReview(new PhpCsFixerReview(self::AUTO_ADD_GIT));
// Review the staged files.
$review->files($fileCollection);
// Check if any matching issues were found.
if ($reporter->hasIssues()) {
$reporter->displayReport();
}
if ($reporter->hasIssueLevel(Issue::LEVEL_ERROR)) {
$io->error('✘ Please fix the errors above.');
exit(1);
} else {
$io->success('✔ Looking good.');
exit(0);
}
}
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
mb_internal_encoding('UTF-8');
try {
list($line, $colonne) = explode("x", $input->getOption("size"));
$symfonyStyle = new SymfonyStyle($input, $output);
$symfonyStyle->title("IA");
$mapRender = !$input->getOption("curse") ? new ConsoleMapRender($output, true) : new NCurseRender($line, $colonne);
if (!$input->getOption("load-dump")) {
$sizeMap = $mapRender->getSize();
$mapProvider = $input->getOption("map") ? new FileMapProvider($input->getOption("map")) : new RandomMapProvider($sizeMap["y"], $sizeMap["x"]);
$map = new MapBuilder($mapProvider->getMap());
$world = new World($map, array($this->addChat(5, 5), $this->addChat(10, 10)));
} else {
$file = $input->getOption("load-dump");
if (!file_exists($file)) {
if (extension_loaded("ncurses") && $mapRender instanceof NCurseRender) {
ncurses_end();
}
$symfonyStyle->error("le fichier {$file} n'existe pas");
return;
}
$world = unserialize(file_get_contents($file))->getFlashMemory()->all()[0]->getData();
}
while (1) {
$this->render($mapRender, $world);
}
} catch (\Exception $e) {
if (extension_loaded("ncurses") && $mapRender instanceof NCurseRender) {
ncurses_end();
}
$symfonyStyle->error($e->getMessage());
return;
}
}
示例9: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->title('Import sentry events');
$organisation = $input->getArgument('organisation');
$project = $input->getArgument('project');
$projectBlacklist = $input->getOption('project-blacklist');
$sentryRequest = new SentryRequest($input->getOption('sentry-url'), $input->getOption('sentry-api-key'));
$projects = [$project];
if (null === $project) {
$projects = $this->application['project.collector']->getSlugs($sentryRequest, $organisation);
}
$progress = new ProgressBar($output);
$progress->start();
foreach ($projects as $project) {
if (in_array($project, $projectBlacklist)) {
continue;
}
$simplifiedEvents = $this->application['event.collector']->getSimplifiedEvents($sentryRequest, $organisation, $project);
foreach ($simplifiedEvents as $simplifiedEvent) {
$this->application['importer']->import($organisation, $project, $simplifiedEvent);
$progress->advance();
}
}
$progress->finish();
$io->newLine(2);
$eventCount = $this->application['db']->fetchColumn('SELECT COUNT(*) FROM events');
$io->success(sprintf('%s events are available.', $eventCount));
}
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
$workerCount = $input->getOption('count');
$queues = $this->createQueues($input->getArgument('queues'));
$output->write($queues);
// This method of worker setup requires an array of queues
if (!is_array($queues)) {
throw new \Exception("Queues not initialized correctly");
}
$workers = array();
for ($i = 0; $i < $workerCount; ++$i) {
$worker = $this->workerFactory->createWorker();
$workerProcess = $this->workerFactory->createWorkerProcess($worker);
foreach ($queues as $queue) {
$worker->addQueue($queue);
}
$workers[] = $workerProcess;
}
$this->foreman->pruneDeadWorkers();
$this->foreman->work($workers, $input->getOption('wait'));
echo sprintf('%d workers attached to the %s queues successfully started.', count($workers), implode($queues, ','));
// echo sprintf(
// 'Workers (%s)',
// implode(', ', $workers)
// );
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$stdout = $output;
$output = new SymfonyStyle($input, $output);
if (false !== strpos($input->getFirstArgument(), ':l')) {
$output->caution('The use of "twig:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:twig" instead.');
}
$twig = $this->getTwigEnvironment();
if (null === $twig) {
$output->error('The Twig environment needs to be set.');
return 1;
}
$filenames = $input->getArgument('filename');
if (0 === count($filenames)) {
if (0 !== ftell(STDIN)) {
throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.');
}
$template = '';
while (!feof(STDIN)) {
$template .= fread(STDIN, 1024);
}
return $this->display($input, $stdout, $output, array($this->validate($twig, $template, uniqid('sf_'))));
}
$filesInfo = $this->getFilesInfo($twig, $filenames);
return $this->display($input, $stdout, $output, $filesInfo);
}
示例12: execute
/**
* Executes the command reparser:list
*
* @param InputInterface $input
* @param OutputInterface $output
* @return integer
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->section($this->user->lang('CLI_DESCRIPTION_REPARSER_AVAILABLE'));
$io->listing($this->reparser_names);
return 0;
}
示例13: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
if (false !== strpos($input->getFirstArgument(), ':d')) {
$output->caution('The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.');
}
$name = $input->getArgument('name');
if (empty($name)) {
$output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
$output->newLine();
$this->listBundles($output);
return;
}
$extension = $this->findExtension($name);
$container = $this->compileContainer();
$configs = $container->getExtensionConfig($extension->getAlias());
$configuration = $extension->getConfiguration($configs, $container);
$this->validateConfiguration($extension, $configuration);
$configs = $container->getParameterBag()->resolveValue($configs);
$processor = new Processor();
$config = $processor->processConfiguration($configuration, $configs);
if ($name === $extension->getAlias()) {
$output->title(sprintf('Current configuration for extension with alias "%s"', $name));
} else {
$output->title(sprintf('Current configuration for "%s"', $name));
}
$output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
}
示例14: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$router = $this->getContainer()->get('router');
$context = $router->getContext();
if (null !== ($method = $input->getOption('method'))) {
$context->setMethod($method);
}
if (null !== ($scheme = $input->getOption('scheme'))) {
$context->setScheme($scheme);
}
if (null !== ($host = $input->getOption('host'))) {
$context->setHost($host);
}
$matcher = new TraceableUrlMatcher($router->getRouteCollection(), $context);
$traces = $matcher->getTraces($input->getArgument('path_info'));
$io->newLine();
$matches = false;
foreach ($traces as $trace) {
if (TraceableUrlMatcher::ROUTE_ALMOST_MATCHES == $trace['level']) {
$io->text(sprintf('Route <info>"%s"</> almost matches but %s', $trace['name'], lcfirst($trace['log'])));
} elseif (TraceableUrlMatcher::ROUTE_MATCHES == $trace['level']) {
$io->success(sprintf('Route "%s" matches', $trace['name']));
$routerDebugCommand = $this->getApplication()->find('debug:router');
$routerDebugCommand->run(new ArrayInput(array('name' => $trace['name'])), $output);
$matches = true;
} elseif ($input->getOption('verbose')) {
$io->text(sprintf('Route "%s" does not match: %s', $trace['name'], $trace['log']));
}
}
if (!$matches) {
$io->error(sprintf('None of the routes match the path "%s"', $input->getArgument('path_info')));
return 1;
}
}
示例15: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$pools = array();
$clearers = array();
$container = $this->getContainer();
$cacheDir = $container->getParameter('kernel.cache_dir');
foreach ($input->getArgument('pools') as $id) {
$pool = $container->get($id);
if ($pool instanceof CacheItemPoolInterface) {
$pools[$id] = $pool;
} elseif ($pool instanceof Psr6CacheClearer) {
$clearers[$id] = $pool;
} else {
throw new \InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
}
}
foreach ($clearers as $id => $clearer) {
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
$clearer->clear($cacheDir);
}
foreach ($pools as $id => $pool) {
$io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
$pool->clear();
}
$io->success('Cache was successfully cleared.');
}