當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ConsoleOutput::writeln方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Output\ConsoleOutput::writeln方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConsoleOutput::writeln方法的具體用法?PHP ConsoleOutput::writeln怎麽用?PHP ConsoleOutput::writeln使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Output\ConsoleOutput的用法示例。


在下文中一共展示了ConsoleOutput::writeln方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $rc = 0;
     try {
         if (!$input->getOption('force')) {
             if (!$input->isInteractive()) {
                 throw new Exception("You have to specify the --force option in order to run this command");
             }
             $confirmQuestion = new ConfirmationQuestion('Are you sure you want to update this concrete5 installation?');
             if (!$this->getHelper('question')->ask($input, $output, $confirmQuestion)) {
                 throw new Exception("Operation aborted.");
             }
         }
         $configuration = new \Concrete\Core\Updater\Migrations\Configuration();
         $output = new ConsoleOutput();
         $configuration->setOutputWriter(new OutputWriter(function ($message) use($output) {
             $output->writeln($message);
         }));
         Update::updateToCurrentVersion($configuration);
     } catch (Exception $x) {
         $output->writeln('<error>' . $x->getMessage() . '</error>');
         $rc = 1;
     }
     return $rc;
 }
開發者ID:seebaermichi,項目名稱:concrete5,代碼行數:25,代碼來源:UpdateCommand.php

示例2: overview

 public static function overview()
 {
     $printer = new ConsoleOutput();
     $printer->writeln('');
     $printer->writeln('Testing Environment');
     $printer->writeln('===================');
     $printer->writeln('Machine : ' . gethostname());
     $printer->writeln('Database : ' . Config::get('database.default'));
 }
開發者ID:sgh1986915,項目名稱:laravel-bizgym,代碼行數:9,代碼來源:TestListener.php

示例3: destroyTestUser

 /**
  * Destroy a user that matches a test user name.
  *
  * @param $role
  * @return $this
  */
 public function destroyTestUser($role)
 {
     $this->output->writeln("deleting test{$role}User...");
     $users = \Drupal::entityQuery('user')->condition("name", "test{$role}User")->execute();
     $users = User::loadMultiple($users);
     foreach ($users as $user) {
         $user->delete();
     }
     return $this;
 }
開發者ID:dustinleblanc,項目名稱:codeception-drupal-8,代碼行數:16,代碼來源:Drupal8.php

示例4: execute

 /**
  * Execute the product template migration
  */
 public function execute()
 {
     $productTemplates = $this->getProductTemplates();
     if (empty($productTemplates)) {
         $this->output->writeln('<info>There is no product template to update<info>');
         return;
     }
     $this->convert($productTemplates);
     $this->output->writeln('<info>Done !</info>');
 }
開發者ID:juliensnz,項目名稱:pim-community-standard,代碼行數:13,代碼來源:migrate_product_template.php

示例5: execute_commands

/**
 * @param $commands
 * @param \Symfony\Component\Console\Output\ConsoleOutput $output
 * @return void
 */
function execute_commands($commands, $output)
{
    foreach ($commands as $command) {
        $output->writeln(sprintf('<info>Executing : </info> %s', $command));
        $p = new \Symfony\Component\Process\Process($command);
        $exit = $p->run(function ($type, $data) use($output) {
            $output->write($data);
        });
        $output->writeln("");
    }
}
開發者ID:karousn,項目名稱:sandbox,代碼行數:16,代碼來源:load_data.php

示例6: processFiles

 public function processFiles($title, array $files, $process)
 {
     $o = new ConsoleOutput();
     $o->writeln('<info>' . $title . '</info>');
     $p = new ProgressBar($o, count($files));
     $p->start();
     foreach ($files as $path) {
         $process($path);
         $p->advance();
     }
     $p->finish();
     $o->writeln('');
 }
開發者ID:yrizos,項目名稱:berk,代碼行數:13,代碼來源:Command.php

示例7: terminate

 /**
  * @inheritdoc
  */
 public function terminate(ResultCollection $collection, ResultCollection $groupedResults)
 {
     $output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true);
     $output->write(str_pad("\r", 80, " "));
     $output->writeln('');
     // score
     $score = $collection->getScore();
     //        if($score) {
     foreach ($score->all() as $name => $value) {
         $output->writeln(sprintf('%s %s', str_pad($name, 35, '.'), str_pad($value, 5, ' ', STR_PAD_LEFT) . ' / ' . Scoring::MAX));
     }
     $output->writeln('');
     //        }
 }
開發者ID:truffo,項目名稱:PhpMetrics,代碼行數:17,代碼來源:Cli.php

示例8: dump

 /**
  * @param $data
  * @param null|int $flags
  */
 public function dump($data, $flags = null)
 {
     if ($flags !== null) {
         if ($flags & self::NEWLINE_BEFORE) {
             $this->output->writeln('');
         }
     }
     $this->cliDumper->dump($this->varCloner->cloneVar($data));
     if ($flags !== null) {
         if ($flags & self::NEWLINE_AFTER) {
             $this->output->writeln('');
         }
     }
 }
開發者ID:sfie,項目名稱:pimcore,代碼行數:18,代碼來源:Dumper.php

示例9: doDownLoad

 public function doDownLoad($limit_array)
 {
     $output = new ConsoleOutput();
     //        $bar = new ProgressBar($output,count($limit_array));
     //        $bar->start();
     //        $bar->setBarWidth(100);
     $i = 0;
     $count = count($limit_array);
     //        $bar->setFormat('debug');
     foreach ($limit_array as $file => $data) {
         //            $package = $this->repository_path."/packages/".$file.".json";
         $versions = $this->repository_path . "/download/" . $file . ".json";
         //            $package = json_decode(file_get_contents($package),true);
         $download = json_decode(file_get_contents($download), true);
         if (!$download) {
             $i++;
             $output->writeln($i . '/' . $count . ' skip');
             continue;
             //                $bar->advance();
         }
         $i++;
         $versions = array_values($download['package']['versions']);
         if (!isset($versions[0]['require'])) {
             $output->writeln($i . '/' . $count . ' skip');
             continue;
         }
         $output->writeln($i . '/' . $count);
         $package_name = strtolower($download['package']['name']);
         $project_name = substr($package_name, 0, strpos($package_name, '/'));
         //            echo strpos($package_name,'/').' '.$package_name."\r\n";exit;
         if (isset($versions[0]['require'])) {
             foreach ($versions[0]['require'] as $k => $v) {
                 R::findOrCreate("CpmRequire", array("package" => $package_name, "project" => $project_name, "require" => strtolower($k), "version" => strtolower($v)));
             }
         }
         if (isset($versions[0]['require-dev'])) {
             foreach ($versions[0]['require-dev'] as $k => $v) {
                 R::findOrCreate("CpmRequireDev", array("package" => $package_name, "project" => $project_name, "require" => strtolower($k), "version" => strtolower($v)));
             }
         }
         if (isset($versions[0]['keywords'])) {
             foreach ($versions[0]['keywords'] as $v) {
                 R::findOrCreate("CpmKeyword", array("package" => $package_name, "project" => $project_name, "keyword" => strtolower($v)));
             }
         }
     }
     //        $bar->finish();
     $output->writeln('');
 }
開發者ID:php-cpm,項目名稱:cpm,代碼行數:49,代碼來源:DownloadCommandHandler.php

示例10: loadExternalConfig

 /**
  * Load the external config files specified by the command line option.
  */
 protected function loadExternalConfig()
 {
     $config = new Repository(static::getDefaultConfig());
     $filesystem = new Filesystem();
     foreach ($this->getConfigFiles($filesystem) as $filename) {
         $this->output->writeln("<info>Reading config from <path>{$filename}</path></info>");
         if ($filesystem->extension($filename) == 'php') {
             $configValues = $filesystem->getRequire($filename);
         } else {
             $configValues = Yaml::parse($filesystem->get($filename));
         }
         $config->set(array_dot($configValues));
     }
     $this->container->instance('config', $config);
 }
開發者ID:parsnick,項目名稱:steak,代碼行數:18,代碼來源:Application.php

示例11: printDebug

 /**
  * Print a message out - useful for debugging
  *
  * @param $string
  */
 protected function printDebug($string)
 {
     if ($this->output === null) {
         $this->output = new ConsoleOutput();
     }
     $this->output->writeln($string);
 }
開發者ID:C3-TKO,項目名稱:smash-api,代碼行數:12,代碼來源:ApiTestCase.php

示例12: execute_commands

/**
 * @param $commands
 * @param \Symfony\Component\Console\Output\ConsoleOutput $output
 *
 * @return boolean
 */
function execute_commands($commands, $output)
{
    foreach ($commands as $command) {
        $output->writeln(sprintf('<info>Executing : </info> %s', $command));
        $p = new \Symfony\Component\Process\Process($command);
        $p->setTimeout(null);
        $p->run(function ($type, $data) use($output) {
            $output->write($data);
        });
        if (!$p->isSuccessful()) {
            return false;
        }
        $output->writeln("");
    }
    return true;
}
開發者ID:awesemo,項目名稱:cms-sandbox,代碼行數:22,代碼來源:load_data.php

示例13: runDatabaseMigrations

 /**
  * @before
  */
 public function runDatabaseMigrations()
 {
     if ($GLOBALS['run_database_migrations']) {
         return;
     }
     $GLOBALS['run_database_migrations'] = true;
     $output = new ConsoleOutput();
     if (getenv('SCHEMA_DUMP') == 1) {
         $output->writeln("Cleaning Database with artisan's <bg=green;options=bold>db:fix && db:schema:dump</>...");
         $this->artisan('db:fix');
         $this->artisan('db:schema:dump', ['--output-file' => 'tests/_data/dump.sql', '--binary' => 'true']);
     } else {
         $output->writeln("Restoring Database with artisan's <bg=green;options=bold>db:schema:restore</>...");
         $this->artisan('db:schema:restore', ['--schema-file' => 'tests/_data/dump.sql']);
     }
 }
開發者ID:KMK-ONLINE,項目名稱:hack_todo,代碼行數:19,代碼來源:TestCase.php

示例14: listNodes

 protected function listNodes(array $nodes, $sortBy = self::SORT_BY_NAME)
 {
     switch ($sortBy) {
         case self::SORT_BY_NAME:
             usort($nodes, function ($a, $b) {
                 return strcasecmp($a['name'], $b['name']);
             });
             break;
         case self::SORT_BY_TIME:
             usort($nodes, function ($a, $b) {
                 return strtotime($a['modifiedDate']) < strtotime($b['modifiedDate']);
             });
             break;
     }
     foreach ($nodes as $node) {
         if ($node->inTrash() && !$this->config['display.trash']) {
             continue;
         }
         $modified = new \DateTime($node['modifiedDate']);
         if ($modified->format('Y') === date('Y')) {
             $date = $modified->format('M d H:m');
         } else {
             $date = $modified->format('M d  Y');
         }
         $name = $node['kind'] === 'FOLDER' ? "<blue>{$node['name']}</blue>" : $node['name'];
         $this->output->writeln(sprintf("%s  %s  %s %s %s %s", $node['id'], $date, str_pad($node['status'], 10), str_pad($node['kind'], 7), str_pad($this->convertFilesize($node['contentProperties']['size'], 0), 6), $name));
     }
 }
開發者ID:Zn4rK,項目名稱:clouddrive-php,代碼行數:28,代碼來源:Command.php

示例15: __construct

 /**
  * @param string $name  application name
  * @param string $version application version
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
 {
     $this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager();
     $generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager);
     if (!$generationDirectoryAccess->check()) {
         $output = new ConsoleOutput();
         $output->writeln('<error>Command line user does not have read and write permissions on var/generation directory.  Please' . ' address this issue before using Magento command line.</error>');
         exit(0);
     }
     /**
      * Temporary workaround until the compiler is able to clear the generation directory
      * @todo remove after MAGETWO-44493 resolved
      */
     if (class_exists(CompilerPreparation::class)) {
         $compilerPreparation = new CompilerPreparation($this->serviceManager, new ArgvInput(), new File());
         $compilerPreparation->handleCompilerEnvironment();
     }
     if ($version == 'UNKNOWN') {
         $directoryList = new DirectoryList(BP);
         $composerJsonFinder = new ComposerJsonFinder($directoryList);
         $productMetadata = new ProductMetadata($composerJsonFinder);
         $version = $productMetadata->getVersion();
     }
     parent::__construct($name, $version);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:30,代碼來源:Cli.php


注:本文中的Symfony\Component\Console\Output\ConsoleOutput::writeln方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。