id()
id() : string
The stable identifier recorded in a frame header.
Returns
string —A short lowercase token such as "zstd", "gzip" or "none".
DEFLATE through `ext-zlib`, which core already requires, so this codec is always available.
It is the floor, not the recommendation. Measured on Drupal-shaped data in 8 KiB frames it
reaches 3.52x where zstd with a trained dictionary reaches 6.20x - 76% more stored bytes for the
same content. A site without ext-zstd still works; it just pays for it, and the settings form
says so with the number measured on that host.
The zlib container is used rather than raw deflate because it carries a checksum, which turns a corrupted frame into an error at decompression instead of into plausible-looking garbage.
levels() : array{min: int, max: int, default: int, fast: int, dense: int}
The compression levels this codec accepts.
The usable range, the default, the level to use on the flush path where throughput matters, and the level to use during compaction where ratio matters.
compress(string $data, ?int $level = null, ?string $dictionary = null) : string
Compresses a buffer.
| string | $data | The bytes to compress. An empty string compresses to an empty string, so that an absent payload never becomes a non-empty frame. |
| ?int | $level | A level within CompressionCodecInterface::levels(), or NULL for the default. |
| ?string | $dictionary | Raw dictionary bytes, or NULL. Ignored by codecs that report no dictionary support, so a caller never has to branch on it. |
The compressed bytes.