PHP-Extension for compressing content with Zopfli a good zlib (gzip, deflate) compatible compressor which produces smallest possible results.
C Other
Latest commit ba7c2bd Mar 15, 2016 @clickalicious Update README.md
Failed to load latest commit information.
docs New clickalicious documentation style Feb 28, 2015
win32 Added Zopfli lib latest // Fixed a small bug in type of 2nd encode ar… Mar 1, 2015
zopfli Added Zopfli lib latest // Fixed a small bug in type of 2nd encode ar… Feb 28, 2015
.editorconfig Updated LICENSE // added .editorconfig // prepared changelog Feb 28, 2015
.gitignore Restructured project Feb 28, 2015
CHANGELOG Updated LICENSE // added .editorconfig // prepared changelog Feb 28, 2015
CONTRIBUTORS Prepared for PECL // added basic stuff Mar 3, 2015
COPYING Prepared for PECL // added basic stuff Mar 3, 2015
CREDITS Prepared for PECL // added basic stuff Mar 3, 2015
EXPERIMENTAL Prepared for PECL // added basic stuff Mar 3, 2015
INSTALL
LICENSE Updated LICENSE // added .editorconfig // prepared changelog Feb 28, 2015
README.md Update README.md Mar 15, 2016
RELEASES Prepared for PECL // added basic stuff Mar 3, 2015
TODO
composer.json
config.m4 Added Zopfli lib latest // Fixed a small bug in type of 2nd encode ar… Feb 28, 2015
config.w32
package.xml
php_zopfli.c
php_zopfli.h Added Zopfli lib latest // Fixed a small bug in type of 2nd encode ar… Feb 28, 2015
zopfli.ncb Restructured project Feb 28, 2015
zopfli.sln initial public commit 0.1 Mar 2, 2013
zopfli.suo Restructured project Feb 28, 2015
zopfli.vcproj Restructured project Feb 28, 2015

README.md

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