isArgDefined() public method

public isArgDefined ( string $arg )
$arg string
Esempio n. 1
0
 /**
  * Bootstrap a server from command line options
  *
  * @param PsrLogger $logger
  * @param \Aerys\Console $console
  * @return \Generator
  */
 public function boot(PsrLogger $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 (array_key_exists("debug", $options)) {
         throw new \DomainException('AERYS_OPTIONS constant contains "debug" key; "debug" option is read-only and only settable to true via the -d command line option');
     }
     $options["debug"] = $console->isArgDefined("debug");
     $options["configPath"] = $configFile;
     return $this->init($logger, $options);
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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));
 }