juanchosl / compression
Grouped tools in order to abstract compression tasks compatible with few formats and encodings.
1.0.x-dev
2026-08-22 11:48 UTC
Requires
- php: ^8.0
- juanchosl/exceptions: 1.0.*
- juanchosl/validators: 1.0.*
Requires (Dev)
- phpstan/phpstan: 1.12.*
- phpunit/phpunit: 9.6.*
This package is auto-updated.
Last update: 2026-08-22 11:48:50 UTC
README
Description
Little methods collection in order to compress/uncompress strings or create/manage compressed files
Install
composer require juanchosl/compression
Data Compression
At first, we can compress/uncompress strings, it is not needed that use a regular file, can be used from/to http messages directly.
- Bzip2 (require bz2 extension) (https://www.php.net/manual/es/book.bzip2.php)
- Pure Gzip RFC 1952
- Lzf (require lzf extension) (https://www.php.net/manual/es/book.lzf.php)
- Gzip/Deflate (require zlib extension) RFC 1951
- Brotli (require brotli extension)
- Zstd (require zstd extension)
How to use
We can select from few extensions, in order to change the format between the available extensions or the specyfic need, with no code changes.
Plain text/data
Compress
$format = new CompressionBrotli($level = 8); $compressed_text = $format->compress($uncompressed_text);
Uncompress
$format = new CompressionZstd(); $uncompressed_text = $format->decompress($compressed_text);