- Compress content with
- Better compression & smaller results - up to 5%!
- Con: This compressor takes more time (~100x slower!) then average zlib compressing
php_zopfli was designed as a compressor for cases where the time to compress doesn't matter but the results should be as small as possible. I decided to implement
Zopfli compression for this special case.
Zopfli produces up to 5% smaller results than average zlib compressors out in the wild.
Zopfli is up to 100x times slower to compress the data.
Put this single line in your php.ini and put the extension in the same place as the other default extensions
Optional configure the default number of iterations in your php.ini. Whenever you call zopfliencode() without the 2nd argument the php.ini default value is used instead.
[Zopfli] zopfli.iterations = 5
php_zopfli can be used as replacement for gzip/zlib-compression. The
Zopfli compression is 100% compatible with gzip + zlib so your browser will understand the
Zopfli output already. Just call zopfliencode() instead of gzencode().
The second argument is the optional iteration counter (a value between 1 and [max?]1000).
<?php $buffer = 'put some longer story here ...'; /* * Use zopfliencode() as replacement for gzencode() * * @param string The string to encode/compress * @param integer Number of iterations for compression (1 - 1000 [default = 5]) */ $data = zopfliencode($buffer, 1); header('Content-Encoding: gzip'); header('Content-Length: '.strlen($data)); header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Pragma: no-cache'); // output data echo $data; ?>
There is currently no documentation.
For a consistent versioning i decided to make use of
Semantic Versioning 2.0.0 http://semver.org. Its easy to understand, very common and known from many other software projects.
- General stability improvements and tests
Participate & share
... yeah. If you're a code monkey too - maybe we can build a force ;) If you would like to participate in either Code, Comments, Documentation, Wiki, Bug-Reports, Unit-Tests, Bug-Fixes, Feedback and/or Critic then please let me know as well!
Thanks to our sponsors and supporters: