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


PHP Output\ConsoleOutput类代码示例

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


在下文中一共展示了ConsoleOutput类的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: createConsoleOutput

 /**
  * @return OutputWriter
  */
 public static function createConsoleOutput()
 {
     $output = new ConsoleOutput();
     return new OutputWriter(function ($message) use($output) {
         $output->write($message, TRUE);
     });
 }
开发者ID:pecinaon,项目名称:sandbox,代码行数:10,代码来源:MigrationsExtension.php

示例3: __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

示例4: writeln

 public function writeln($sprintf)
 {
     $arguments = func_get_args();
     $arguments[0] .= PHP_EOL;
     $message = call_user_func_array("sprintf", $arguments);
     $this->laravelConsoleOutput->write($message);
 }
开发者ID:jlaso,项目名称:tradukoj-laravel,代码行数:7,代码来源:ConsoleOutputAdapter.php

示例5: execute_commands

/**
 * @param $commands
 * @param \Symfony\Component\Console\Output\ConsoleOutput $output
 *
 * @return boolean
 */
function execute_commands($commands, $output)
{
    foreach ($commands as $command) {
        list($command, $message, $allowFailure) = $command;
        $output->write(sprintf(' - %\'.-70s', $message));
        $return = array();
        if (is_callable($command)) {
            $success = $command($output);
        } else {
            $p = new \Symfony\Component\Process\Process($command);
            $p->setTimeout(null);
            $p->run(function ($type, $data) use(&$return) {
                $return[] = $data;
            });
            $success = $p->isSuccessful();
        }
        if (!$success && !$allowFailure) {
            $output->writeln('<error>KO</error>');
            $output->writeln(sprintf('<error>Fail to run: %s</error>', is_callable($command) ? '[closure]' : $command));
            foreach ($return as $data) {
                $output->write($data, false, OutputInterface::OUTPUT_RAW);
            }
            $output->writeln("If the error is coming from the sandbox,");
            $output->writeln("please report the issue to https://github.com/sonata-project/sandbox/issues");
            return false;
        } else {
            if (!$success) {
                $output->writeln("<info>!!</info>");
            } else {
                $output->writeln("<info>OK</info>");
            }
        }
    }
    return true;
}
开发者ID:NadirZenith,项目名称:sonata-boilerplate,代码行数:41,代码来源:load_data.php

示例6: run

 /**
  * Method overridden to add output customizations and use the output object
  * for application logging.
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $output) {
         $output = new ConsoleOutput();
         $output->setFormatter(new OutputFormatter($output->isDecorated()));
     }
     return parent::run($input, $output);
 }
开发者ID:zroger,项目名称:feather,代码行数:12,代码来源:Application.php

示例7: checkDependencies

 public function checkDependencies()
 {
     $output = new ConsoleOutput();
     if (!extension_loaded('mbstring')) {
         $output->writeln("\n<error>Missing Dependency: Please install the Multibyte String Functions.</error>\n" . "More help: http://www.php.net/manual/en/mbstring.installation.php\n", $this->outputFormat);
         exit(1);
     }
 }
开发者ID:regothic,项目名称:markdown-resume,代码行数:8,代码来源:Resume.php

示例8: run

 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $output) {
         $output = new ConsoleOutput();
     }
     $output->getFormatter()->getStyle('info')->setForeground('magenta');
     $output->getFormatter()->getStyle('comment')->setForeground('cyan');
     return parent::run($input, $output);
 }
开发者ID:100hz,项目名称:hive-console,代码行数:9,代码来源:Application.php

示例9: printMessage

 private static function printMessage($s, $tag)
 {
     if (PHP_SAPI === 'cli') {
         $output = new ConsoleOutput();
         $output->writeln('<' . $tag . '>' . $s . '</' . $tag . '>');
     } else {
         error_log(strtoupper($tag) . ': ' . $s);
     }
 }
开发者ID:martinlindhe,项目名称:php-debughelper,代码行数:9,代码来源:Logger.php

示例10: 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

示例11: setUp

 protected function setUp()
 {
     $this->oldApplicationContext = ApplicationContext::getInstance();
     $this->applicationContext = $this->createApplicationContext();
     $this->applicationContext->setPlugin($this->getPlugin());
     $this->applicationContext->setComponent('input', new ArgvInput());
     $output = new ConsoleOutput();
     $output->setDecorated(false);
     $this->applicationContext->setComponent('output', $output);
     ApplicationContext::setInstance($this->applicationContext);
 }
开发者ID:rsky,项目名称:stagehand-testrunner,代码行数:11,代码来源:TestCase.php

示例12: register

 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app['migrations.output_writer'] = new OutputWriter(function ($message) {
         $output = new ConsoleOutput();
         $output->writeln($message);
     });
     $app['migrations.directory'] = null;
     $app['migrations.name'] = 'Migrations';
     $app['migrations.namespace'] = null;
     $app['migrations.table_name'] = 'migration_versions';
 }
开发者ID:Leemo,项目名称:silex-doctrine-migrations-provider,代码行数:19,代码来源:DoctrineMigrationsProvider.php

示例13: install

 /**
  * install
  *
  * @return void
  */
 public static function install()
 {
     $output = new ConsoleOutput();
     $style = new OutputFormatterStyle('green');
     $output->getFormatter()->setStyle('green', $style);
     $assets = array('resources/cache', 'resources/log', 'web/assets');
     foreach ($assets as $asset) {
         self::createAndChmod($asset, 0777);
         $output->writeln(sprintf('<green>Generating "%s" asset dir</green>', $asset));
     }
     exec('php console assetic:dump');
 }
开发者ID:ronanguilloux,项目名称:silexmarkdown,代码行数:17,代码来源:Script.php

示例14: testShutdownToConsoleOutput

 public function testShutdownToConsoleOutput()
 {
     ob_start();
     $out = new ConsoleOutput();
     $err = new StreamOutput(fopen('php://memory', 'w', false));
     $out->setErrorOutput($err);
     $app = new Application('test', 'beta');
     $app->configure(null, $out);
     Application::shutdownFunction($app);
     rewind($err->getStream());
     $this->assertContains('exit()', stream_get_contents($err->getStream()));
 }
开发者ID:inetprocess,项目名称:sugarcli,代码行数:12,代码来源:ApplicationTest.php

示例15: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var KernelInterface $kernel */
     $kernel = $this->container->get('kernel');
     if (in_array($kernel->getEnvironment(), $this->getEnvironments())) {
         $this->doLoad($manager);
     } else {
         $ouput = new ConsoleOutput();
         $msg = '...Not for ' . $kernel->getEnvironment() . ' environment';
         $ouput->writeln('  <comment>></comment> <comment>' . $msg . '</comment>');
     }
 }
开发者ID:danielsreichenbach,项目名称:symfony3-template,代码行数:15,代码来源:AbstractDataFixture.php


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