Hi

Am 2025-02-18 14:22, schrieb Paul Dragoonis:
Having spent many years in PHP-FIG and lots of effort trying to build one "standard" for lots of implementations that differ. I just want to point out that I think we should avoid trying to make a standard design for all the Compression drivers and features and instead agree that things (Enums?)
will and should differ from drive too driver and that'd okay.

Given that all compression algorithms work in a “put source data in get compressed data out” fashion, I believe it is reasonable to have an interface specifying that to allow for proper pluggability in the output pipeline:

    if (in_array('brotli', $request->getHeader('accept-encoding'))) {
$compressor = new \Compression\Brotli\Compressor(\Compression\Brotli\Mode::Text); } elseif (in_array('zstd', $request->getHeader('accept-encoding'))) {
        $compressor = new \Compression\Zstd\Compressor();
} elseif (in_array('gzip', $request->getHeader('accept-encoding'))) {
        $compressor = new \Compression\Gzip\Compressor(level: 6);
    } else {
        $compressor = new NullCompressor();
    }

    echo $compressor->compress($response->getBody());

I trust Jordi to come up with a reasonable API design.

Best regards
Tim Düsterhus

Reply via email to