Aerys\Bootstrapper::boot PHP Method

boot() public method

Bootstrap a server from command line options
public boot ( Psr\Log\LoggerInterface $logger, Console $console ) : Generator
$logger Psr\Log\LoggerInterface
$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);
    }