1# Snappy Extension for PHP 2 3[![Linux](https://github.com/kjdev/php-ext-snappy/workflows/Linux/badge.svg?branch=master)](https://github.com/kjdev/php-ext-snappy/actions?query=workflow%3ALinux+branch%3Amaster) 4[![Windows](https://github.com/kjdev/php-ext-snappy/workflows/Windows/badge.svg?branch=master)](https://github.com/kjdev/php-ext-snappy/actions?query=workflow%3AWindows+branch%3Amaster) 5 6This extension allows Snappy. 7 8Documentation for Snappy can be found at 9[» http://google.github.io/snappy/](http://google.github.io/snappy/). 10 11## Build from sources 12 13 % git clone --recursive --depth=1 https://github.com/kjdev/php-ext-snappy.git 14 % cd php-ext-snappy 15 % phpize 16 % ./configure 17 % make 18 % make install 19 20To use the system library 21 22``` bash 23% ./configure --with-snappy-includedir=/usr 24``` 25 26## Distribution binary packages 27 28### Fedora / CentOS / RHEL 29 30RPM packages of this extension are available in [» Remi's RPM repository](https://rpms.remirepo.net/) and are named **php-snappy**. 31 32## Configuration 33 34php.ini: 35 36 extension=snappy.so 37 38## Function : snappy_compress 39 40string snappy_compress( string $data ) 41 42### parameters 43 44data: 45 46 The data to compress. 47 48### return values 49 50The compressed string or FALSE if an error occurred. 51 52## Function : snappy_uncompress 53 54string snappy_uncompress( string $data ) 55 56### parameters 57 58name: 59 60 The data compressed by snappy_gzcompress(). 61 62### return values 63 64The original uncompressed data or FALSE on error. 65 66## Example 67 68 $compressed = snappy_compress('Compress me'); 69 70 $uncompressed = snappy_uncompress($compressed); 71 72 echo $uncompressed; 73 74## Ubuntu Tipps 75 76snappy requires C++ and therefore might require for you to install the g++ or build-essential package. 77 78If you get an error about "this file requires compiler and library support" you might need to enfore the compilation with 79 80 $ export CXXFLAGS=-std=c++11 81 $ phpize 82 $ ./configure 83 $ make 84