本文整理汇总了PHP中Console::getArg方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::getArg方法的具体用法?PHP Console::getArg怎么用?PHP Console::getArg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Console
的用法示例。
在下文中一共展示了Console::getArg方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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]);
}
示例2: __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);
}
}
示例3: 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;
}
示例4: getMethod
/**
* Get method name.
*
* @return string
*/
protected function getMethod()
{
if ($this->method) {
return $this->method;
}
$method = isset($this->methodParam) ? Console::getOpt($this->methodParam) : Console::getArg(isset($this->methodParam) && !isset($this->paramDelim) ? 1 : 0);
if (isset($this->paramDelim) && !empty($method) && ($pos = strpos($this->paramDelim, $method)) !== false) {
$method = substr($method, $pos + 1);
}
return $method;
}
示例5: boot
/**
* Bootstrap a server from command line options
*
* @param \Aerys\Logger $logger
* @param \Aerys\Console $console
* @return \Generator
*/
public function boot(Logger $logger, Console $console) : \Generator
{
$configFile = self::selectConfigFile((string) $console->getArg("config"));
$logger->info("Using config file found at {$configFile}");
// may return Promise or Generator for async I/O inside config file
$returnValue = (include $configFile);
if (!$returnValue) {
throw new \DomainException("Config file inclusion failure: {$configFile}");
}
if (is_callable($returnValue)) {
$returnValue = \call_user_func($returnValue);
}
if ($returnValue instanceof \Generator) {
yield from $returnValue;
} elseif ($returnValue instanceof Promise) {
(yield $returnValue);
}
if (!defined("AERYS_OPTIONS")) {
$options = [];
} elseif (is_array(AERYS_OPTIONS)) {
$options = AERYS_OPTIONS;
} else {
throw new \DomainException("Invalid AERYS_OPTIONS constant: expected array, got " . gettype(AERYS_OPTIONS));
}
if ($console->isArgDefined("debug")) {
$options["debug"] = true;
}
$options["configPath"] = $configFile;
$options = $this->generateOptionsObjFromArray($options);
$vhosts = new VhostContainer();
$ticker = new Ticker($logger);
$server = new Server($options, $vhosts, $logger, $ticker, [new Http1Driver(), new Http2Driver()]);
$bootLoader = function (Bootable $bootable) use($server, $logger) {
$booted = $bootable->boot($server, $logger);
if ($booted !== null && !$booted instanceof Middleware && !is_callable($booted)) {
throw new \InvalidArgumentException("Any return value of " . get_class($bootable) . '::boot() must return an instance of Aerys\\Middleware and/or be callable, got ' . gettype($booted) . ".");
}
return $booted ?? $bootable;
};
$hosts = \call_user_func($this->hostAggregator) ?: [new Host()];
foreach ($hosts as $host) {
$vhost = self::buildVhost($host, $bootLoader);
$vhosts->use($vhost);
}
return $server;
}
示例6: doStart
protected function doStart(Console $console) : \Generator
{
// Shutdown the whole server in case we needed to stop during startup
register_shutdown_function(function () use($console) {
if (!$this->server) {
// ensure a clean reactor for clean shutdown
$reactor = \Amp\reactor();
\Amp\reactor(\Amp\driver());
\Amp\wait((new CommandClient((string) $console->getArg("config")))->stop());
\Amp\reactor($reactor);
}
});
$server = (yield from $this->bootstrapper->boot($this->logger, $console));
(yield $server->start());
$this->server = $server;
\Amp\onReadable($this->ipcSock, function ($watcherId) {
\Amp\cancel($watcherId);
yield from $this->stop();
});
}
示例7: generateWorkerCommand
private function generateWorkerCommand(Console $console) : string
{
$parts[] = \PHP_BINARY;
if ($ini = \get_cfg_var("cfg_file_path")) {
$parts[] = "-c";
$parts[] = $ini;
}
$parts[] = "-d";
$parts[] = "zend.assertions=" . ini_get("zend.assertions");
$parts[] = __DIR__ . "/../bin/aerys-worker";
$parts[] = "-i";
$parts[] = $this->ipcServerUri;
if ($console->isArgDefined("config")) {
$parts[] = "-c";
$parts[] = $console->getArg("config");
}
if ($console->isArgDefined("color")) {
$parts[] = "--color";
$parts[] = $console->getArg("color");
}
if ($console->isArgDefined("log")) {
$parts[] = "-l";
$parts[] = $console->getArg("log");
}
return implode(" ", array_map("escapeshellarg", $parts));
}
示例8: generateWorkerCommand
private function generateWorkerCommand(Console $console) : string
{
$parts[] = \PHP_BINARY;
if ($ini = \get_cfg_var("cfg_file_path")) {
$parts[] = "-c \"{$ini}\"";
}
$parts[] = "-d zend.assertions=" . ini_get("zend.assertions");
$parts[] = __DIR__ . "/../bin/aerys-worker";
$parts[] = "-i {$this->ipcServerUri}";
if ($console->isArgDefined("config")) {
$parts[] = "-c " . $console->getArg("config");
}
if ($console->isArgDefined("color")) {
$parts[] = "--color " . $console->getArg("color");
}
if ($console->isArgDefined("log")) {
$parts[] = "-l " . $console->getArg("log");
}
return implode(" ", $parts);
}