本文整理汇总了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");
}
}
}
}
示例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);