Skip to content

PHP-Extension for compressing content with Zopfli a good zlib (gzip, deflate) compatible compressor which produces smallest possible results.

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
COPYING
Notifications You must be signed in to change notification settings

SawMaineK/php_zopfli

 
 

Repository files navigation

--- # php_zopfli

Logo of php_zopfli PHP-Extension for compressing content with Zopfli a good zlib (gzip, deflate) compatible compressor which produces smallest possible results.

Build Status Scrutinizer clickalicious premium Apache 2.0
GitHub issues Coverage Status GitHub release GitHub stars

Features

  • Compress content with Zopfli
  • Better compression & smaller results - up to 5%!
  • Con: This compressor takes more time (~100x slower!) then average zlib compressing

Philosophy

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.

Installation

Put this single line in your php.ini and put the extension in the same place as the other default extensions

extension=php_zopfli.(so|dll)

Config

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

Example

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;

?>

Documentation

There is currently no documentation.

Versioning

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.

Roadmap

  • General stability improvements and tests

More Information

Zopfli was written by Jyrki Alakuijala, Ph.D. and Lode Vandevenne, M.Sc. from Google Inc. You will find the projects homepage here and the whitepaper here.

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!

Sponsors

Thanks to our sponsors and supporters:

JetBrains Navicat

About

PHP-Extension for compressing content with Zopfli a good zlib (gzip, deflate) compatible compressor which produces smallest possible results.

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
COPYING

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 99.1%
  • Makefile 0.9%