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


PHP Cli::execute方法代码示例

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


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

示例1: main

 /**
  * Main method.
  */
 public static function main()
 {
     list($command, $arguments, $config) = self::preProcess();
     $migration = new Migration($config);
     try {
         $cli = new Cli();
         $cli->execute($migration, $command, $arguments, $config);
     } catch (\Exception $e) {
         $debug = $migration->getConfig()->get('debug');
         $colors = $migration->getConfig()->get('colors');
         if (isset($debug) && $debug) {
             if ($colors) {
                 fputs(STDERR, pack('c', 0x1b) . "[1;37;41m" . $e . pack('c', 0x1b) . "[0m\n");
             } else {
                 fputs(STDERR, $e);
             }
         } else {
             if ($colors) {
                 fputs(STDERR, pack('c', 0x1b) . "[1;37;41m" . $e->getMessage() . pack('c', 0x1b) . "[0m\n");
             } else {
                 fputs(STDERR, $e->getMessage() . "\n");
             }
         }
     }
 }
开发者ID:kohkimakimoto,项目名称:lib-migration,代码行数:28,代码来源:Cli.php

示例2: execute

<?php

/**
 * Написать простой CLI скрипт, который принимает на ввод строку, переворачивает ее
 * и удаляет все гласные и выводит на экран.
 * Пример: input: Hello world! output: !dlrw llH
 */
class Cli
{
    public function execute($params)
    {
        require_once __DIR__ . '/Autoload_psr4.php';
        $invertor = new \Cli\Invertor\String();
        $inverted = $invertor->getInverted($params[1]);
        $filter = new \Cli\Filter\String\Vowels();
        $filtered = $filter->getFiltered($inverted);
        $template = new \Cli\Template\Php();
        $template->setTemplate(__DIR__ . '/Cli/Template/tpl/output.php');
        $output = $template->process(array('filtered' => $filtered));
        echo $output;
    }
}
Cli::execute($argv);
开发者ID:rhaps107,项目名称:dummy_test,代码行数:23,代码来源:Cli.php


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