Documentation Packages Getting Started FAQ Support

Http Server ⋅ Options

The Options class represents possible settings for the HTTP server. The Options is an immutable class, it never modifies itself but returns a new object instead.

isInDebugMode(): bool

Indicates whether the server is in debug mode (true) or in production mode (false).

The server mode is set to production by default.

withDebugMode(): Options

Sets the server mode to debug.

withoutDebugMode(): Options

Sets the server mode to production.

getConnectionLimit(): int

Returns the maximum number of connections that can be handled by the server at a single time. If that number is exceeded, new connections are dropped.

Default connection limit is 10000.

withConnectionLimit(int $limit): Options

Sets the maximum number of connections the server should accept at one time. If that number is exceeded, new connections are dropped.

Connection limit must be greater than or equal to one.

Default connection limit is 10000.

getConnectionsPerIpLimit(): int

Returns the maximum number of connections allowed from an individual /32 IPv4 or /56 IPv6 range.

Default connections per IP limit is 30.

withConnectionsPerIpLimit(int $count): Options

Sets the maximum number of connections to allow from a single IP address.

Connections per IP limit must be greater than or equal to one.

Default connections per IP limit is 30.

getConnectionTimeout(): int

Returns amount of time in seconds a connection may be idle before it is automatically closed.

Default connection timeout is 15 seconds.

withConnectionTimeout(int $seconds): Options

Sets the number of seconds a connection may be idle before it is automatically closed.

Connection timeout must be greater than or equal to one second.

Default connection timeout is 15 seconds.

getBodySizeLimit(): int

Returns maximum HTTP request body size in bytes.

Default body size limit is 131072 bytes (128k).

withBodySizeLimit(int $bytes): Options

Sets maximum request body size in bytes. Individual request body may be increased by calling RequestBody::increaseSizeLimit.

Body size limit must be greater than or equal to zero.

Default body size limit is 131072 bytes (128k).

getHeaderSizeLimit(): int

Returns maximum size of the request header section in bytes.

Default header size limit is 32768 bytes (32k).

withHeaderSizeLimit(int $bytes): Options

Sets maximum size of the request header section in bytes.

Header size limit must be greater than zero.

Default header size limit is 32768 bytes (32k).

getConcurrentStreamLimit(): int

Returns the maximum number of concurrent HTTP/2 streams per connection.

Default concurrent streams limit is 20.

withConcurrentStreamLimit(int $streams): Options

Sets the maximum number of concurrent HTTP/2 streams per connection.

Concurrent streams limit must be greater than zero.

Default concurrent streams limit is 20.

getMinimumAverageFrameSize(): int

Returns minimum average frame size required if more than the maximum number of frames per second are received on an HTTP/2 connection.

Default minimum average frame size is 1024 bytes (1k).

withMinimumAverageFrameSize(int $size): Options

Sets minimum average frame size required if more than the maximum number of frames per second are received on an HTTP/2 connection.

Minimum average frame size must be greater than zero.

Default minimum average frame size is 1024 bytes (1k).

getFramesPerSecondLimit(): int

Returns the maximum number of HTTP/2 frames per second before the average length minimum is enforced.

Default frames per second limit is 60.

withFramesPerSecondLimit(int $frames): Options

Sets the maximum number of HTTP/2 frames per second before the average length minimum is enforced.

Maximum number of HTTP/2 frames per second setting must be greater than zero.

Default frames per second limit is 60.

getChunkSize(): int

Returns the maximum number of bytes to read from a client per read.

Default frames per second limit is 8192 (8k).

withChunkSize(int $bytes): Options

Sets the maximum number of bytes to read from a client per read.

Maximum number of HTTP/2 frames per second setting must be greater than zero.

Default frames per second limit is 8192 (8k).

getAllowedMethods(): array

Returns an array of allowed request methods.

Default allowed methods are: ["GET", "POST", "PUT", "PATCH", "HEAD", "OPTIONS", "DELETE"]

withAllowedMethods(array $allowedMethods): Options

Sets an array of allowed request methods.

Allowed methods must be an array of non-empty strings and contain GET and HEAD methods: ["GET", "HEAD"]

Default allowed methods are: ["GET", "POST", "PUT", "PATCH", "HEAD", "OPTIONS", "DELETE"]

isHttp2UpgradeAllowed(): bool

Returns true if HTTP/2 requests may be established through upgrade requests or prior knowledge.

HTTP/2 requests through upgrade requests are disabled by default.

withHttp2Upgrade(): Options

Enables unencrypted upgrade or prior knowledge requests to HTTP/2.

withoutHttp2Upgrade(): Options

Disables unencrypted upgrade or prior knowledge requests to HTTP/2.

isCompressionEnabled(): bool

Returns true if compression is enabled.

Compression is enabled by default.

withCompression(): Options

Enables compression-by-default.

withoutCompression(): Options

Disables compression-by-default.