Aerys\Host class Host

Summary

Properties

Methods

Properties

Methods

__construct — public function __construct()
No documentation.
__clone — public function __clone()
No documentation.
expose — public function expose(string $address, int $port): self

Assign the IP and port on which to listen

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.

Type Parameter Description Default Value
string $address The IPv4 or IPv6 interface to listen to none
int $port The port number on which to listen none
name — public function name(string $name): self

Assign a domain name (e.g. localhost or mysite.com or subdomain.mysite.com)

A host name is only required if a server exposes more than one host. If a name is not defined the server will default to "localhost"

Type Parameter Description Default Value
string $name No documentation. none
use — public function use(callable|Aerys\Middleware|Aerys\Bootable|Aerys\Monitor $action): self

Use a callable request action or Middleware

Host actions are invoked to service requests in the order in which they are added.

Type Parameter Description Default Value
callable|Aerys\Middleware|Aerys\Bootable|Aerys\Monitor $action No documentation. none
encrypt — public function encrypt(string $certificate, string|null $key = null, array $options = []): self

Define TLS encryption settings for this host

Type Parameter Description Default Value
string $certificate A string path pointing to your SSL/TLS certificate none
string|null $key A string path pointing to your SSL/TLS key file (null if the certificate file is containing the key already) null
array $options An optional array mapping additional SSL/TLS settings []
redirect — public function redirect(string $absoluteUri, int $redirectCode = 307): self

Redirect all requests that aren't serviced by an action callable

NOTE: the redirect URI must match the format "scheme://hostname.tld" (with optional port and path).

The following example redirects all unencrypted requests to the equivalent encrypted resource:

 <?php
 // Redirect http://mysite.com to https://mysite.com
 $host = new Aerys\Host;
 $host->setName("mysite.com");
 $host->redirect("https://mysite.com");
Type Parameter Description Default Value
string $absoluteUri The location to which we wish to redirect none
int $redirectCode The HTTP redirect status code (300-399) 307
separateIPv4Binding — public function separateIPv4Binding(): bool
No documentation.
export — public function export(): array

Retrieve an associative array summarizing the host definition

getDefinitions — public function getDefinitions(): array

Used by the server bootstrapper to access host configs created by the application