expose() public méthode

The address may be any valid IPv4 or IPv6 address. The "0.0.0.0" indicates "all IPv4 interfaces" and is appropriate for most users. Use "::" to indicate "all IPv6 interfaces". To indicate "all IPv4 *and* IPv6 interfaces", use a "*" wildcard character. Note that "::" may also listen on some systems on IPv4 interfaces. PHP currently does not expose the IPV6_V6ONLY constant. Any valid port number [1-65535] may be used. Port numbers lower than 256 are reserved for well-known services (like HTTP on port 80) and port numbers less than 1024 require root access on UNIX-like systems. The default port for encrypted sockets (https) is 443. If you plan to use encryption with this host you'll generally want to use port 443.
public expose ( string $address, integer $port ) : Host
$address string The IPv4 or IPv6 interface to listen to
$port integer The port number on which to listen
Résultat Host
Exemple #1
0
        }
        $sslEnabled = true;
        $sslCert = realpath($config['web-api']['ssl']['cert-path']);
        if (!$sslCert) {
            throw new InvalidConfigurationException('Invalid SSL certificate path');
        }
        $sslKey = null;
        if (isset($config['web-api']['ssl']['key-path']) && !($sslKey = realpath($config['web-api']['ssl']['key-path']))) {
            throw new InvalidConfigurationException('Invalid SSL key path');
        }
        $sslContext = $config['web-api']['ssl']['context'] ?? [];
        $host->encrypt($sslCert, $sslKey, $sslContext);
    }
    $bindAddr = $config['web-api']['bind-addr'] ?? '127.0.0.1';
    $bindPort = (int) ($config['web-api']['bind-port'] ?? ($sslEnabled ? 1337 : 1338));
    $host->expose($bindAddr, $bindPort);
    if (isset($config['web-api']['host'])) {
        $host->name($config['web-api']['host']);
    }
    /** @var WebAPIServer $api */
    $api = $injector->make(WebAPIServer::class);
    $host->use($api->getRouter());
    (new Bootstrapper(function () use($host) {
        return [$host];
    }))->init(new AerysLogger($injector->make(Logger::class)))->start();
}
onError(function (\Throwable $e) {
    fwrite(STDERR, "\nAn exception was not handled:\n\n{$e}\n\n");
});
try {
    run();