本文整理汇总了PHP中Output::colorize方法的典型用法代码示例。如果您正苦于以下问题:PHP Output::colorize方法的具体用法?PHP Output::colorize怎么用?PHP Output::colorize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Output
的用法示例。
在下文中一共展示了Output::colorize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exec
/**
* Execute an external command, generate friendly output and return the result
*
* @param string $command
* @param boolean $formatted Return formatted output in addition to raw
* @param string $prefix
* @return array
*/
public static function exec($command, $formatted = false, $prefix = '> ')
{
$commandOriginal = $command;
$command = $command . ' 2>&1';
// stifle output; we'll include it in the returned array
$result = exec($command, $commandOutput, $exitCode);
$output['raw'] = '';
if ($formatted) {
$output['formatted'] = '';
$color = $exitCode == 0 ? 'green' : 'red';
}
foreach ($commandOutput as $line) {
$output['raw'] .= $line . PHP_EOL;
if ($formatted) {
$output['formatted'] .= Output::colorize($prefix . $line, $color) . PHP_EOL;
}
}
$output['raw'] = trim($output['raw']);
return ['command' => $commandOriginal, 'output' => $output, 'exitCode' => $exitCode];
}
示例2: __construct
/**
* @param Source $src
* @param mixed $tasks
* @param Phulp $phulp
*/
public function __construct(Source $src, $tasks, Phulp $phulp)
{
$phulp->getLoop()->addPeriodicTimer(0.002, function () use($src, $tasks, $phulp) {
foreach ($src->getDistFiles() as $distFile) {
if (!empty($distFile->getFullpath()) && file_exists($distFile->getFullpath())) {
clearstatcache();
$timeChange = @filemtime(rtrim($distFile->getFullpath(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $distFile->getName());
if ($distFile->getLastChangeTime() < $timeChange) {
Output::out('[' . Output::colorize((new \DateTime())->format('H:i:s'), 'light_gray') . ']' . ' The file "' . Output::colorize(rtrim($distFile->getRelativePath(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $distFile->getName(), 'light_magenta') . '" was changed');
$distFile->setLastChangeTime($timeChange);
if (is_array($tasks)) {
$phulp->start($tasks);
} elseif (is_callable($tasks)) {
$tasks($phulp);
}
}
}
}
});
}