Re: [RFC] Modern Compression (zstd, brotli)

From: Date: Tue, 18 Feb 2025 13:55:32 +0000
Subject: Re: [RFC] Modern Compression (zstd, brotli)
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
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

Thread (11 messages)

« previous php.internals (#126449) next »