PHP Class Aerys\Host

Mostrar archivo Open project: amphp/aerys Class Usage Examples

Public Methods

Method Description
__clone ( )
__construct ( )
encrypt ( string $certificate, string $key = null, array $options = [] ) : Host Define TLS encryption settings for this host
export ( ) : array Retrieve an associative array summarizing the host definition
expose ( string $address, integer $port ) : Host Assign the IP and port on which to listen
getDefinitions ( ) : array Used by the server bootstrapper to access host configs created by the application
name ( string $name ) : Host Assign a domain name (e.g. localhost or mysite.com or subdomain.mysite.com)
redirect ( string $absoluteUri, integer $redirectCode = 307 ) : Host Redirect all requests that aren't serviced by an action callable
separateIPv4Binding ( ) : boolean
use ( callable | aerys\Middleware | aerys\Bootable | aerys\Monitor $action ) : Host Use a callable request action or Middleware

Method Details

__clone() public method

public __clone ( )

__construct() public method

public __construct ( )

encrypt() public method

Define TLS encryption settings for this host
public encrypt ( string $certificate, string $key = null, array $options = [] ) : Host
$certificate string A string path pointing to your SSL/TLS certificate
$key string A string path pointing to your SSL/TLS key file (null if the certificate file is containing the key already)
$options array An optional array mapping additional SSL/TLS settings
return Host

export() public method

Retrieve an associative array summarizing the host definition
public export ( ) : array
return array

expose() public method

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
return Host

getDefinitions() public static method

Used by the server bootstrapper to access host configs created by the application
public static getDefinitions ( ) : array
return array

name() public method

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"
public name ( string $name ) : Host
$name string
return Host

redirect() public method

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: setName("mysite.com"); $host->redirect("https://mysite.com");
public redirect ( string $absoluteUri, integer $redirectCode = 307 ) : Host
$absoluteUri string The location to which we wish to redirect
$redirectCode integer The HTTP redirect status code (300-399)
return Host

separateIPv4Binding() public static method

public static separateIPv4Binding ( ) : boolean
return boolean

use() public method

Host actions are invoked to service requests in the order in which they are added.
public use ( callable | aerys\Middleware | aerys\Bootable | aerys\Monitor $action ) : Host
$action callable | aerys\Middleware | aerys\Bootable | aerys\Monitor
return Host