src/site/php/brotli fix.php

Constants

BROTLI_GENERIC

BROTLI_GENERIC = 0

BROTLI_TEXT

BROTLI_TEXT = 1

BROTLI_FONT

BROTLI_FONT = 2

BROTLI_COMPRESS_LEVEL_MIN

BROTLI_COMPRESS_LEVEL_MIN = 0

BROTLI_COMPRESS_LEVEL_MAX

BROTLI_COMPRESS_LEVEL_MAX = 11

BROTLI_COMPRESS_LEVEL_DEFAULT

BROTLI_COMPRESS_LEVEL_DEFAULT = 11

Functions

cfw_brotli()

cfw_brotli(string  $op, string  $data, int  $level = 11, int  $mode = 0, string  $dict = '') : array{ok: bool, data?: string, error?: string}

Runs one op over the bridge.

Parameters

string $op

The operation, compress or uncompress.

string $data

The bytes to transform.

int $level

A brotli quality, 0 to 11.

int $mode

BROTLI_GENERIC, BROTLI_TEXT or BROTLI_FONT.

string $dict

A preset dictionary, or an empty string for none. The host refuses one.

Returns

array{ok: bool, data?: string, error?: string} —

The decoded reply, or the reason it failed.

cfw_brotli_fail()

cfw_brotli_fail(string  $name, string  $reason) : false

Raises the diagnostic ext-brotli raises, then answers FALSE like it does.

Parameters

string $name

The PHP function that failed.

string $reason

What ext-brotli would have said.

Returns

false —

brotli_compress()

brotli_compress(string  $data, int  $level = 11, int  $mode = 0, string|null  $dict = null) : string|false

Compresses a string with brotli.

Parameters

string $data

The bytes to compress.

int $level

A brotli quality, 0 to 11.

int $mode

BROTLI_GENERIC, BROTLI_TEXT or BROTLI_FONT.

string|null $dict

Not supported on this host; a non-empty value is refused.

Returns

string|false —

The compressed bytes, or FALSE on failure.

brotli_uncompress()

brotli_uncompress(string  $data, string|null  $dict = null) : string|false

Decompresses a brotli stream.

Parameters

string $data

The brotli stream.

string|null $dict

Not supported on this host; a non-empty value is refused.

Returns

string|false —

The decompressed bytes, or FALSE on failure.