本文整理汇总了PHP中Console类的典型用法代码示例。如果您正苦于以下问题:PHP Console类的具体用法?PHP Console怎么用?PHP Console使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Console类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: processGames
public function processGames()
{
if ($this->site->lookupgames == 1) {
$console = new Console($this->echooutput);
$console->processConsoleReleases();
}
}
开发者ID:ehsanguru,项目名称:nnplus,代码行数:7,代码来源:postprocess.php
示例2: boot
/**
* Bootstrap a server from command line options
*
* @param \Aerys\Logger $logger
* @param \Aerys\Console $console
* @return \Aerys\Server
*/
public function boot(Logger $logger, Console $console) : Server
{
$configFile = $this->selectConfigFile((string) $console->getArg("config"));
$logger->info("Using config file found at {$configFile}");
if (!(include $configFile)) {
throw new \DomainException("Config file inclusion failure: {$configFile}");
} elseif (!defined("AERYS_OPTIONS")) {
$options = [];
} elseif (is_array(AERYS_OPTIONS)) {
$options = AERYS_OPTIONS;
} else {
throw new \DomainException("Invalid AERYS_OPTIONS constant: array expected, got " . gettype(AERYS_OPTIONS));
}
if ($console->isArgDefined("debug")) {
$options["debug"] = true;
}
$options = $this->generateOptionsObjFromArray($options);
$vhosts = new VhostContainer();
$ticker = new Ticker($logger);
$server = new Server($options, $vhosts, $logger, $ticker);
$bootLoader = function (Bootable $bootable) use($server, $logger) {
return $bootable->boot($server, $logger);
};
$hosts = \call_user_func($this->hostAggregator) ?: [new Host()];
foreach ($hosts as $host) {
$vhost = $this->buildVhost($host, $bootLoader);
$vhosts->use($vhost);
}
return $server;
}
开发者ID:hunslater,项目名称:aerys,代码行数:37,代码来源:Bootstrapper.php
示例3: doStart
protected function doStart(Console $console) : \Generator
{
if ($console->isArgDefined("restart")) {
$this->logger->critical("You cannot restart a debug aerys instance via command");
exit(1);
}
$server = (yield from $this->bootstrapper->boot($this->logger, $console));
(yield $server->start());
$this->server = $server;
}
开发者ID:beentrill,项目名称:aerys,代码行数:10,代码来源:DebugProcess.php
示例4: __construct
public function __construct(Console $console, $ipcSock)
{
if ($console->isArgDefined("color")) {
$this->setAnsify($console->getArg("color"));
}
$level = $console->getArg("log");
$level = isset(self::LEVELS[$level]) ? self::LEVELS[$level] : $level;
$this->setOutputLevel($level);
$onWritable = $this->makePrivateCallable("onWritable");
$this->ipcSock = $ipcSock;
$this->writeWatcherId = \Amp\onWritable($ipcSock, $onWritable, ["enable" => false]);
}
开发者ID:hunslater,项目名称:aerys,代码行数:12,代码来源:IpcLogger.php
示例5: __construct
public function __construct(Console $console)
{
$this->console = $console;
if ($console->isArgDefined("color")) {
$value = $console->getArg("color");
$this->setAnsiColorOption($value);
}
if ($console->isArgDefined("log")) {
$level = $console->getArg("log");
$level = isset(self::LEVELS[$level]) ? self::LEVELS[$level] : $level;
$this->setOutputLevel($level);
}
}
开发者ID:beentrill,项目名称:aerys,代码行数:13,代码来源:ConsoleLogger.php
示例6: run
public function run(Console $console, Db $db)
{
$this->db = $db;
if (!$console->hasParams()) {
$this->showHelp();
} else {
foreach ($console->getParams() as $command => $value) {
if (method_exists($this, $command)) {
$this->{$command}($value);
}
}
}
}
开发者ID:alexboo,项目名称:traffics-task2,代码行数:13,代码来源:App.php
示例7: Display
public function Display(Console $con, $resIps, $errorsOnly)
{
foreach ($this->GetChangedLines() as $line) {
$con->WritePart('[' . $con->Colorize('ERROR', Console::C_RED) . '] ');
$con->WritePart($con->Colorize($resIps ? substr(str_pad($this->ResolveIP($line->ip), 48), 0, 48) : str_pad($line->ip, 16), Console::C_YELLOW) . ' ');
$con->WritePart($con->Colorize(str_pad($line->domain, 32), Console::C_BROWN) . ' ');
$long_mesg = $con->Colorize($line->message, Console::C_RED);
$con->WriteLine($long_mesg);
}
}
开发者ID:gvelchev,项目名称:httpdmon,代码行数:10,代码来源:ErrorlogFileMonitor.php
示例8: doStart
protected function doStart(Console $console) : \Generator
{
if ($console->isArgDefined("restart")) {
$this->logger->critical("You cannot restart a debug aerys instance via command");
exit(1);
}
if (ini_get("zend.assertions") === "-1") {
$this->logger->warning("Running aerys in debug mode with assertions disabled is not recommended; " . "enable assertions in php.ini (zend.assertions = 1) " . "or disable debug mode (-d) to hide this warning.");
} else {
ini_set("zend.assertions", 1);
}
$server = (yield from $this->bootstrapper->boot($this->logger, $console));
(yield $server->start());
$this->server = $server;
}
开发者ID:vlakarados,项目名称:aerys,代码行数:15,代码来源:DebugProcess.php
示例9: __construct
public function __construct($workingDir = '.', $info, $commandsSeq = array())
{
parent::__construct($workingDir, $info, $commandsSeq);
Console::initCore();
$this->root_dir = Config::get('ROOT_DIR');
$this->models_dir = Config::get('models_dir');
}
开发者ID:point,项目名称:cassea,代码行数:7,代码来源:CmdController.php
示例10: call
function call($arguments = null)
{
Console::debugEx(LOG_DEBUG1, __CLASS__, "Delegate invocation");
foreach ($this->callable as $classes) {
@call_user_func_array($classes, (array) $arguments);
}
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:7,代码来源:delegates.php
示例11: create
/**
* Comando de consola para crear un modelo
*
* @param array $params parametros nombrados de la consola
* @param string $model modelo
* @throw KumbiaException
*/
public function create($params, $model)
{
// nombre de archivo
$file = APP_PATH . 'models';
// obtiene el path
$path = explode('/', trim($model, '/'));
// obtiene el nombre de modelo
$model_name = array_pop($path);
if (count($path)) {
$dir = implode('/', $path);
$file .= "/{$dir}";
if (!is_dir($file) && !FileUtil::mkdir($file)) {
throw new KumbiaException("No se ha logrado crear el directorio \"{$file}\"");
}
}
$file .= "/{$model_name}.php";
// si no existe o se sobreescribe
if (!is_file($file) || Console::input("El modelo existe, �desea sobrescribirlo? (s/n): ", array('s', 'n')) == 's') {
// nombre de clase
$class = Util::camelcase($model_name);
// codigo de modelo
ob_start();
include CORE_PATH . 'console/generators/model.php';
$code = '<?php' . PHP_EOL . ob_get_clean();
// genera el archivo
if (file_put_contents($file, $code)) {
echo "-> Creado modelo {$model_name} en: {$file}" . PHP_EOL;
} else {
throw new KumbiaException("No se ha logrado crear el archivo \"{$file}\"");
}
}
}
开发者ID:ocidfigueroa,项目名称:sice,代码行数:39,代码来源:model_console.php
示例12: renderRecursive
private function renderRecursive($nod)
{
$ret = '';
for ($n = 0; $n < $nod->childNodes->length; $n++) {
$cn = $nod->childNodes->item($n);
if ($cn->namespaceURI == self::NS_LITEMARKUP) {
$t = explode(':', $cn->nodeName);
switch ($t[1]) {
case 'debug':
$ret .= "THIS IS THE DEBUGGING INFO";
break;
default:
Console::warn("Unknown LiteMarkup tag: %s", $cn->nodeName);
}
} else {
switch ($cn->nodeName) {
case '#text':
$ret .= $cn->nodeValue;
break;
default:
$ret .= '<' . $cn->nodeName . '>' . $this->renderRecursive($cn) . '</' . $cn->nodeName . '>';
break;
}
}
}
return $ret;
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:27,代码来源:templates.php
示例13: getInstance
/**
*
* @return Console
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
开发者ID:NeoCortexBg,项目名称:sitemap_checker,代码行数:11,代码来源:console.php
示例14: exception
function exception(Exception $e)
{
logger::emerg("Unhandled exception: (%s) %s in %s:%d", get_class($e), $e->getMessage(), str_replace(BASE_PATH, '', $e->getFile()), $e->getLine());
Console::debugEx(0, get_class($e), "Unhandled exception: (%s) %s in %s:%d", get_class($e), $e->getMessage(), str_replace(BASE_PATH, '', $e->getFile()), $e->getLine());
$f = file($e->getFile());
foreach ($f as $i => $line) {
$mark = $i + 1 == $e->getLine() ? '=> ' : ' ';
$f[$i] = sprintf(' %05d. %s', $i + 1, $mark) . $f[$i];
$f[$i] = str_replace("\n", "", $f[$i]);
}
$first = $e->getLine() - 4;
if ($first < 0) {
$first = 0;
}
$last = $e->getLine() + 3;
if ($last >= count($f)) {
$last = count($f) - 1;
}
$source = join("\n", array_slice($f, $first, $last - $first));
Console::debugEx(0, get_class($e), Console::backtrace(0, $e->getTrace(), true));
Console::debugEx(LOG_LOG, "Exception", "Source dump of %s:\n%s", str_replace(BASE_PATH, '', $e->getFile()), $source);
$rv = 1;
logger::emerg("Exiting with return code %d after exception.", $rv);
Console::debugEx(LOG_BASIC, __CLASS__, "Exiting with return code %d after exception.", $rv);
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:25,代码来源:exception.php
示例15: process
function process()
{
Console::initCore();
if ($r = ArgsHolder::get()->getOption('count')) {
$this->count = $r;
}
if (($c = ArgsHolder::get()->shiftCommand()) == 'help') {
return $this->cmdHelp();
}
try {
IO::out("");
$sql = 'SELECT * FROM ' . self::TABLE . ' where not isnull(finished_at) and not
isnull(locked_at) and isnull(failed_at) ORDER BY run_at DESC';
if ($this->count) {
$list = DB::query($sql . ' LIMIT ' . $this->count);
} else {
$list = DB::query($sql);
}
if (!count($list)) {
IO::out("No finished work!", IO::MESSAGE_FAIL);
return;
}
io::out(sprintf("%-10s %-7s %-3s %-20s %-20s %-19s %-4s %-5s", "~CYAN~id", "queue", "pr", "run_at", "locked_at", "finished_at", "att", "call_to~~~"));
foreach ($list as $l) {
$handler = unserialize($l["handler"]);
io::out(sprintf("%-4s %-7s %-3s %-20s %-20s %-20s %-3s %-5s", $l["id"], $l["queue"], $l["priority"], $l["run_at"], $l["locked_at"], $l["finished_at"], $l["attempts"], $handler["class"] . "::" . $handler["method"] . "(...)"));
}
} catch (Exception $e) {
io::out($e->getMessage(), IO::MESSAGE_FAIL);
return;
}
IO::out("");
}
开发者ID:point,项目名称:cassea,代码行数:33,代码来源:CmdBgworkCompleted.php
示例16: main
/**
* Start server
*
* @param string[] args
*/
public static function main(array $args)
{
$stor = new TestingStorage();
$stor->add(new TestingCollection('/', $stor));
$stor->add(new TestingCollection('/.trash', $stor));
$stor->add(new TestingElement('/.trash/do-not-remove.txt', $stor));
$stor->add(new TestingCollection('/htdocs', $stor));
$stor->add(new TestingElement('/htdocs/file with whitespaces.html', $stor));
$stor->add(new TestingElement('/htdocs/index.html', $stor, "<html/>\n"));
$stor->add(new TestingCollection('/outer', $stor));
$stor->add(new TestingCollection('/outer/inner', $stor));
$stor->add(new TestingElement('/outer/inner/index.html', $stor));
$auth = newinstance('lang.Object', array(), '{
public function authenticate($user, $password) {
return ("testtest" == $user.$password);
}
}');
$protocol = newinstance('peer.ftp.server.FtpProtocol', array($stor, $auth), '{
public function onShutdown($socket, $params) {
$this->answer($socket, 200, "Shutting down");
$this->server->terminate= TRUE;
}
}');
isset($args[0]) && $protocol->setTrace(Logger::getInstance()->getCategory()->withAppender(new FileAppender($args[0])));
$s = new Server('127.0.0.1', 0);
try {
$s->setProtocol($protocol);
$s->init();
Console::writeLinef('+ Service %s:%d', $s->socket->host, $s->socket->port);
$s->service();
Console::writeLine('+ Done');
} catch (Throwable $e) {
Console::writeLine('- ', $e->getMessage());
}
}
开发者ID:Gamepay,项目名称:xp-framework,代码行数:40,代码来源:TestingServer.class.php
示例17: actionIndex
public function actionIndex($isForced = false, $isDebug = false)
{
$console = Console::getInstance($isForced, $isDebug);
$console->debugStart('Entered');
// if (mail('[email protected]', 'test', 'test message')) {
// $console->writeLine('OK');
// } else {
// $console->writeLine('Failure');
// }
$newExecutors = Site::getNewExecutors('2015-11-19 12:20:00');
$report = '';
foreach ($newExecutors as $e) {
$sites = Site::model()->findAllByAttributes(array('executor_id' => $e));
if (count($sites) < 1) {
continue;
}
$report .= String::build('Positions for "{keyword}" ({date_from} - {date_to})', array('keyword' => $sites[0]->keyword->name, 'date_from' => Time::toPretty($sites[0]->updated_at), 'date_to' => Time::toPretty($sites[count($sites) - 1]->updated_at))) . PHP_EOL;
foreach ($sites as $s) {
$report .= String::build('{position}: {site}', array('position' => $s->position, 'site' => String::rebuildUrl($s->link, false, false, true, false))) . PHP_EOL;
}
}
$console->writeLine($report);
$console->debugEnd();
return;
}
开发者ID:evgeniys-hyuna,项目名称:leadsite,代码行数:25,代码来源:TestCommand.php
示例18: gravalog
function gravalog($numero, $texto, $pagina = null, $linha = null, $contexto = null)
{
$ddf = fopen(DIR_LOGS . "/" . date('Y.M.d') . ".log", 'a');
if ($ddf) {
$datalog = date('d.m.Y H:i:s');
$txt = "::[" . $datalog . "]--|" . ip() . "|----------------------\n";
$txt .= "(" . $numero . ") " . $texto . "\n";
if (!is_null($pagina)) {
$txt .= "Pagina: " . $pagina . "\n";
}
if (!is_null($linha)) {
$txt .= "Linha: " . $linha . "\n";
}
$txt .= "\n";
if (PROFILER) {
if (class_exists("Console")) {
$e = new ErrorException($texto, 0, $numero, $pagina, $linha);
Console::logError($e, $texto);
}
}
if (fwrite($ddf, $txt)) {
return true;
if (DEBUG) {
alert('Arquivo gravado com sucesso', false);
}
}
} else {
if (DEBUG) {
alert('Erro ao gravar arquivo', false);
}
}
fclose($ddf);
}
开发者ID:patrix,项目名称:oraculum,代码行数:33,代码来源:logs.php
示例19: input
public static function input($prompt, $color = null)
{
Console::write($prompt, $color);
$finput = fopen("php://stdin", "r");
$input = fgets($finput);
return str_replace("\n", "", $input);
}
开发者ID:kopiro,项目名称:brutor,代码行数:7,代码来源:Console.php
示例20: logger
function logger($level, $msg, $method = null)
{
static $labels = array(100 => 'DEBUG', 200 => 'INFO', 250 => 'NOTICE', 300 => 'WARNING', 400 => 'ERROR', 500 => 'CRITICAL', 550 => 'ALERT', 600 => 'EMERGENCY', 700 => 'ALL');
// make sure $level has the correct value
if (is_int($level) and !isset($labels[$level]) or is_string($level) and !array_search(strtoupper($level), $labels)) {
throw new \FuelException('Invalid level "' . $level . '" passed to logger()');
}
if (is_string($level)) {
$level = array_search(strtoupper($level), $labels);
}
// get the levels defined to be logged
$loglabels = \Config::get('log_threshold');
// bail out if we don't need logging at all
if ($loglabels == \Fuel::L_NONE) {
return false;
}
// if profiling is active log the message to the profile
if (\Config::get('profiling')) {
\Console::log($method . ' - ' . $msg);
}
// if it's not an array, assume it's an "up to" level
if (!is_array($loglabels)) {
$a = array();
foreach ($labels as $l => $label) {
$l >= $loglabels and $a[] = $l;
}
$loglabels = $a;
}
// do we need to log the message with this level?
if (!in_array($level, $loglabels)) {
return false;
}
return \Log::instance()->log($level, (empty($method) ? '' : $method . ' - ') . $msg);
}
开发者ID:marietta-adachi,项目名称:website,代码行数:34,代码来源:base.php
注:本文中的Console类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论