当前位置: 首页>>代码示例>>PHP>>正文


PHP OutputInterface::writeLn方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Output\OutputInterface::writeLn方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputInterface::writeLn方法的具体用法?PHP OutputInterface::writeLn怎么用?PHP OutputInterface::writeLn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Output\OutputInterface的用法示例。


在下文中一共展示了OutputInterface::writeLn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $environment = $input->getArgument('environment');
     $template = $input->getArgument('template');
     $scalingProfile = $input->getOption('scaling-profile');
     $name = $input->getOption('name');
     $stack = $this->configStackMapper->create($template, $environment, $scalingProfile, $name);
     $output->writeLn('<info>Template</info>');
     $output->write($stack->getTemplate()->getBodyJSON());
     $output->writeLn('');
     $output->writeLn('<info>Parameters</info>');
     $table = new Table($output);
     $table->setHeaders(['Key', 'Value']);
     foreach ($stack->getParameters() as $key => $value) {
         $table->addRow([$key, $value]);
     }
     $table->render();
     $output->writeLn('');
     $output->writeLn('<info>Tags</info>');
     $table = new Table($output);
     $table->setHeaders(['Key', 'Value']);
     foreach ($stack->getTags() as $key => $value) {
         $table->addRow([$key, $value]);
     }
     $table->render();
 }
开发者ID:jonathanbull,项目名称:stack-manager,代码行数:29,代码来源:PreviewStackCommand.php

示例2: __invoke

 /**
  * Runs when silly routes the command to us.
  * ie: ```ppm install```
  *
  * @param  IOutput $output
  * @return void
  */
 public function __invoke(IOutput $output)
 {
     // Save the output interface so we can use it later
     $this->output = $output;
     // Tell the world we have started installing stuff
     $this->output->writeLn("Starting Installer");
     // Attach to Observables
     $this->downloader->attach($this);
     $this->cleaner->attach($this);
     // Read in the root composer.json file
     $composer = $this->reader->getComposerObject();
     // Loop through all "require" packages, downloading them, recursively.
     if (isset($composer['require'])) {
         $this->downloadPackages($composer['require']);
     }
     // Loop through all "require-dev" packages, downloading them.
     // This is done recursively just like the normal require packages but
     // only these first level packages are downloaded, as to say we do not
     // download any "require-dev" packages of a "require-dev" package.
     if (isset($composer['require-dev'])) {
         $this->downloadPackages($composer['require-dev']);
     }
     // Remove anything that shouldn't exist
     $this->cleaner->clean($this->downloader->getDownloaded());
     // Discover any namespace conflicts
     $conflicts = $this->conflicts->discover($this->downloader->getDownloaded());
     // Re-Name conflicting types.
     $replacements = $this->renamer->renameConflicts($conflicts);
     // Generate auto loader.
     $this->autoload->generate($this->downloader->getDownloaded(), $replacements);
     $autoloader = (require $this->vendorDir . '/autoload.php');
     // Create proxies for renamed types.
     //$this->proxy->generate($replacements, $autoloader);
 }
开发者ID:brad-jones,项目名称:ppm,代码行数:41,代码来源:Install.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dryRun = $input->getOption('dry-run');
     $content = $this->processConfig($this->crontab);
     $enviroment = isset($content['env']) ? $content['env'] : array();
     $commands = isset($content['commands']) ? $content['commands'] : array();
     foreach ($commands as $entry) {
         preg_match('/\\[(.*)\\](.*)/', $entry, $match);
         $tab = $match[1];
         $command = $match[2];
         $cron = CronExpression::factory($tab);
         $output->writeLn('<info>- Checking schedule entry: ' . $tab . '</info>');
         // If the cron is not due for execution, just skip
         if (!$cron->isDue()) {
             continue;
         }
         // Construct the fork command
         $fork = $command . " > " . $this->log . " 2>&1 & echo \$!";
         $output->writeLn('<info>- Command:</info> ' . $fork);
         // Start a new process
         if (!$dryRun) {
             exec($fork, $pid);
             $pid = current($pid);
             $output->writeLn('<info>- Process created:</info> ' . $pid);
         } else {
             $output->writeLn('<info>- Skipping execution (--dry-run)</info>');
         }
     }
 }
开发者ID:arcturial,项目名称:schedule,代码行数:32,代码来源:RunCommand.php

示例4: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $repo = $this->getContainer()->get('lichess.repository.game');
     $dm = $this->getContainer()->get('doctrine.odm.mongodb.document_manager');
     $query = array('isAi' => array('$exists' => false));
     $select = array('players.isAi' => true);
     $collection = $dm->getDocumentCollection($repo->getDocumentName())->getMongoCollection();
     $total = $collection->count($query);
     $batchSize = 10000;
     $it = 0;
     $output->writeLn(sprintf('Found %d games to process', $total));
     for ($it = 0, $itMax = ceil($total / $batchSize); $it < $itMax; $it++) {
         $cursor = $collection->find($query, $select)->limit($batchSize)->skip($it * $batchSize);
         $games = iterator_to_array($cursor);
         $nbIsAi = 0;
         foreach ($games as $id => $game) {
             if (!empty($game['players'][0]['isAi']) || !empty($game['players'][1]['isAi'])) {
                 $collection->update(array('_id' => $id), array('$set' => array('isAi' => true)), array('safe' => true));
                 $nbIsAi++;
             }
         }
         $output->writeLn(sprintf('%d%% %d/%d %d/%d', ($it + 1) * $batchSize * 100 / $total, ($it + 1) * $batchSize, $total, $nbIsAi, $batchSize));
         sleep(5);
     }
     $output->writeLn('Done');
 }
开发者ID:hotfics,项目名称:lichess-old,代码行数:29,代码来源:DenormalizeIsAiCommand.php

示例5: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fs = new Filesystem();
     $repoUrl = 'git://github.com/ornicar/lichess.wiki.git';
     //$repoUrl = '/home/thib/lichess.wiki/';
     $repoName = 'lichess_wiki';
     $repoDir = '/tmp';
     $repo = $repoDir . '/' . $repoName;
     $fs->remove($repo);
     $command = sprintf('cd %s && git clone %s %s', $repoDir, $repoUrl, $repoName);
     system($command);
     $finder = new Finder();
     $mdFiles = $finder->files()->depth(0)->name('*.md')->in($repo);
     $pages = array();
     foreach ($mdFiles as $mdFile) {
         $name = preg_replace('/^(.+)\\.md$/', '$1', $mdFile->getFileName());
         if ($name == "Home") {
             continue;
         }
         $output->writeLn('* ' . $name);
         $command = sprintf('sundown %s/%s', $repo, $mdFile->getFileName());
         exec($command, $out);
         $body = implode($out, "\n");
         unset($out);
         $pages[] = new WikiPage($name, $body);
     }
     if (empty($pages)) {
         throw new \Exception('No pages to save');
     }
     $this->getContainer()->get('lichess.repository.wiki_page')->replaceWith($pages);
     $this->getContainer()->get('doctrine.odm.mongodb.document_manager')->flush();
     $output->writeLn('Flushed');
 }
开发者ID:hotfics,项目名称:lichess-old,代码行数:36,代码来源:WikiCommand.php

示例6: execute

 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $newrelic = $this->newrelic;
     $appNames = $newrelic->getDeploymentNames();
     if (!$appNames) {
         $output->writeLn("<error>No deployment application configured.</error>");
         return self::EXIT_NO_APP_NAMES;
     }
     $exitCode = 0;
     foreach ($appNames as $appName) {
         $response = $this->performRequest($newrelic->getApiKey(), $this->createPayload($appName, $input));
         switch ($response['status']) {
             case 200:
             case 201:
                 $output->writeLn(sprintf("Recorded deployment to '%s' (%s)", $appName, $input->getOption('description') ? $input->getOption('description') : date('r')));
                 break;
             case 403:
                 $output->writeLn(sprintf("<error>Deployment not recorded to '%s': API key invalid</error>", $appName));
                 $exitCode = self::EXIT_UNAUTHORIZED;
                 break;
             case null:
                 $output->writeLn(sprintf("<error>Deployment not recorded to '%s': Did not understand response</error>", $appName));
                 $exitCode = self::EXIT_HTTP_ERROR;
                 break;
             default:
                 $output->writeLn(sprintf("<error>Deployment not recorded to '%s': Received HTTP status %d</error>", $appName, $response['status']));
                 $exitCode = self::EXIT_HTTP_ERROR;
                 break;
         }
     }
     return $exitCode;
 }
开发者ID:Aerendir,项目名称:EkinoNewRelicBundle,代码行数:35,代码来源:NotifyDeploymentCommand.php

示例7: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filename = 'app/config/parameters.yml';
     if (!file_exists($filename)) {
         throw new RuntimeException("No such file: " . $filename);
     }
     $data = file_get_contents($filename);
     $config = Yaml::parse($data);
     if (isset($config['pdo'])) {
         $pdo = $config['pdo'];
     } else {
         if (!isset($config['parameters']['pdo'])) {
             throw new RuntimeException("Can't find pdo configuration");
         }
         $pdo = $config['parameters']['pdo'];
     }
     $partten = '/^(\\w+)\\:\\/\\/(\\w+)\\:(.+)\\@([a-zA-Z0-9\\.]+)\\/(\\w+)/';
     preg_match($partten, $pdo, $matches);
     if ($matches) {
         if ('mysql' == $matches[1] || 'mysqli' == $matches[1]) {
             $cmd = 'mysql -u ' . $matches[2] . ' --password=' . $matches[3] . ' -h ' . $matches[4] . ' ' . $matches[5];
         } else {
             $output->writeLn('<error>PDO is not mysql type</error>');
         }
     } else {
         $output->writeLn('<error>Cannot parse DSN</error>');
     }
     $output->write($cmd);
 }
开发者ID:radvance,项目名称:radvance,代码行数:32,代码来源:MySQLConnectCommand.php

示例8: runCommandProcess

 private function runCommandProcess($cmd, OutputInterface $output)
 {
     $process = new Process($cmd);
     $output->writeLn('<comment>' . $process->getCommandLine() . '</comment>');
     $process->run();
     $output->writeLn($process->getOutput());
 }
开发者ID:radvance,项目名称:radvance,代码行数:7,代码来源:CodeUpdateCommand.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configLoader = new ConfigurationLoader(new FileLocator());
     $config = $configLoader->load('config.yml');
     // Print the list of available groups
     if ($input->getOption('list')) {
         foreach (array_keys($config->getGroups()) as $item) {
             $output->writeln(sprintf('<comment>%s</comment>', $item));
         }
         return;
     }
     // Compile all assets declred in config
     if ($input->getOption('compile-all')) {
         // Do the Compile
         $compiler = new CssCompiler(new Filesystem());
         foreach ($config->getGroups() as $name => $group) {
             $compiler->compile($group['files'], $group['destination']);
             $output->writeLn(sprintf('Group <info>%s</info> [OK]', $name));
         }
         return;
     }
     // Compile the specified group, if one is specified
     $groupName = $input->getOption('group');
     $group = $config->getGroup($groupName);
     if (is_null($group)) {
         throw new \Exception('The group you have specified does not exist in your config file');
     }
     // Do the Compile
     $compiler = new CssCompiler(new Filesystem());
     $compiler->compile($group['files'], $group['destination']);
     $output->writeLn(sprintf('Group <info>%s</info> [OK]', $groupName));
 }
开发者ID:extragsm,项目名称:assets-compiler,代码行数:32,代码来源:CssCommand.php

示例10: execute

 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeLn("Received argument <info>entity</info> as <comment>" . $input->getArgument('entity') . "</comment>");
     $output->writeLn("Received option <info>fields</info> as <comment>" . $input->getOption('fields') . "</comment>");
     $output->writeLn("Received option <info>opt</info> as <comment>" . $input->getOption('opt') . "</comment>");
     $output->writeLn("<comment>Successfully finished purified</comment>");
 }
开发者ID:mmz-srf,项目名称:GearmanBundle,代码行数:10,代码来源:PurifyInputCommand.php

示例11: execute

 /**
  * Execute the filter command
  *
  * @param  InputInterface  $input  Input object
  * @param  OutputInterface $output Output object
  * @return null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $col = new \Expose\FilterCollection();
     $col->load();
     $filters = $col->getFilterData();
     $id = $input->getOption('id');
     if ($id !== false) {
         $idList = explode(',', $id);
         foreach ($idList as $id) {
             if (array_key_exists($id, $filters)) {
                 $detail = "[" . $id . "] " . $filters[$id]->getDescription() . "\n";
                 $detail .= "\tRule: " . $filters[$id]->getRule() . "\n";
                 $detail .= "\tTags: " . implode(', ', $filters[$id]->getTags()) . "\n";
                 $detail .= "\tImpact: " . $filters[$id]->getImpact() . "\n";
                 $output->writeLn($detail);
             } else {
                 $output->writeLn('Filter ID ' . $id . ' not found!');
             }
         }
         return;
     }
     foreach ($filters as $filter) {
         echo $filter->getId() . ': ' . $filter->getDescription() . "\n";
     }
     return;
 }
开发者ID:rendler-denis,项目名称:expose,代码行数:33,代码来源:FilterCommand.php

示例12: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $repo = $this->getContainer()->get('lichess.repository.game');
     $batchSize = 1000;
     $sleep = 15;
     $ids = $repo->findCandidatesToCleanup(999999);
     $nb = count($ids);
     $output->writeLn(sprintf('Found %d games of %d to remove', $nb, $repo->createQueryBuilder()->getQuery()->count()));
     if (!$input->getOption('execute')) {
         return;
     }
     do {
         try {
             $ids = $repo->findCandidatesToCleanup($batchSize);
             $nb = count($ids);
             $output->writeLn(sprintf('Found %d games of %d to remove', $nb, $repo->createQueryBuilder()->getQuery()->count()));
             if ($nb == 0) {
                 return;
             }
             $output->writeLn(sprintf('Removing %d games...', $nb));
             $repo->removeByIds($ids);
             if ($nb == $batchSize) {
                 $output->writeLn('Sleep ' . $sleep . ' seconds');
                 sleep($sleep);
             }
         } catch (\MongoCursorTimeoutException $e) {
             $output->writeLn('<error>Time out, sleeping 60 seconds</error>');
             sleep(60);
         }
     } while ($nb > 0);
 }
开发者ID:hafeez3000,项目名称:lichess,代码行数:34,代码来源:GameCleanupCommand.php

示例13: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->factory = $this->getContainer()->get('mautic.factory');
     $queueMode = $this->factory->getParameter('queue_mode');
     // check to make sure we are in queue mode
     if ($queueMode != 'command_process') {
         $output->writeLn('Webhook Bundle is in immediate process mode. To use the command function change to command mode.');
         return 0;
     }
     $id = $input->getOption('webhook-id');
     /** @var \Mautic\WebhookBundle\Model\WebhookModel $model */
     $model = $this->factory->getModel('webhook');
     if ($id) {
         $webhook = $model->getEntity($id);
         $webhooks = $webhook !== null && $webhook->isPublished() ? array($id => $webhook) : array();
     } else {
         // make sure we only get published webhook entities
         $webhooks = $model->getEntities(array('filter' => array('force' => array(array('column' => 'e.isPublished', 'expr' => 'eq', 'value' => 1)))));
     }
     if (!count($webhooks)) {
         $output->writeln('<error>No published webhooks found. Try again later.</error>');
         return;
     }
     $output->writeLn('<info>Processing Webhooks</info>');
     try {
         $model->processWebhooks($webhooks);
     } catch (\Exception $e) {
         $output->writeLn('<error>' . $e->getMessage() . '</error>');
     }
     $output->writeLn('<info>Webhook Processing Complete</info>');
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:34,代码来源:ProcessWebhookQueuesCommand.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var ImportAddressService $importAddressService */
     $importAddressService = $this->getHelper('container')->getByType('StreetApi\\Services\\ImportAddressService');
     $cityId = $input->getArgument('cityId');
     $xmlFile = simplexml_load_file($importAddressService->getRootDir() . '/../adresy.xml');
     if (!$xmlFile) {
         $output->writeln(PHP_EOL . '<error>Missing source file!</error>');
         return 1;
     }
     try {
         $output->writeLn('<info>Start importing addresses</info>');
         $totalCount = $xmlFile->count();
         $output->writeln(PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL);
         $progressBar = new ProgressBar($output, $totalCount);
         $progressBar->setFormat('%message%' . PHP_EOL . '%bar% %percent:3s% %' . PHP_EOL . 'count: %current%/%max%' . PHP_EOL . 'time:  %elapsed:6s%/%estimated:-6s%' . PHP_EOL);
         $progressBar->setBarCharacter('<info>■</info>');
         $progressBar->setEmptyBarCharacter(' ');
         $progressBar->setProgressCharacter('');
         $progressBar->setRedrawFrequency(ceil($totalCount / 100));
         $progressBar->start();
         $importAddressService->import($xmlFile, $progressBar, $cityId);
         $output->writeLn(PHP_EOL . '<info>Importing addresses finished</info>');
         return 0;
     } catch (\Exception $e) {
         $output->writeLn('<error>' . $e->getMessage() . '</error>');
         return 1;
     }
 }
开发者ID:neogenia,项目名称:mvcr-street-api,代码行数:29,代码来源:ImportAddressCommand.php

示例15: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $date = new \DateTime('-2 hours');
     $dm = $this->getContainer()->get('doctrine.odm.mongodb.document_manager');
     $postRemover = $this->getContainer()->get('herzult_forum.remover.post');
     $topicRemover = $this->getContainer()->get('herzult_forum.remover.topic');
     $posts = $this->getContainer()->get('herzult_forum.repository.post')->createQueryBuilder()->field('createdAt')->gt($date)->getQuery()->execute()->toArray();
     $posts = array_filter($posts, function ($post) {
         return !$post->hasAuthor();
     });
     $output->writeLn(sprintf('Will remove %d posts', count($posts)));
     foreach ($posts as $post) {
         $output->writeLn(substr($post->getMessage(), 0, 80));
         try {
             if ($post->getNumber() == 1) {
                 $topicRemover->remove($post->getTopic());
             } else {
                 $postRemover->remove($post);
             }
         } catch (\Exception $e) {
             $output->writeLn($e->getMessage());
         }
         $dm->flush();
     }
     $output->writeLn('Done');
 }
开发者ID:hotfics,项目名称:lichess-old,代码行数:29,代码来源:RemoveRecentAnonymousCommand.php


注:本文中的Symfony\Component\Console\Output\OutputInterface::writeLn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。