Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjdev/php-ext-snappy
Snappy Extension for PHP
https://github.com/kjdev/php-ext-snappy
Last synced: 4 days ago
JSON representation
Snappy Extension for PHP
- Host: GitHub
- URL: https://github.com/kjdev/php-ext-snappy
- Owner: kjdev
- License: other
- Created: 2012-07-27T08:25:55.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-11-25T21:47:26.000Z (about 2 months ago)
- Last Synced: 2024-12-30T23:14:40.875Z (11 days ago)
- Language: PHP
- Homepage:
- Size: 1.18 MB
- Stars: 131
- Watchers: 12
- Forks: 36
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: COPYING.snappy
Awesome Lists containing this project
README
# Snappy Extension for PHP
[![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)
[![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)This extension allows Snappy.
Documentation for Snappy can be found at
[» http://google.github.io/snappy/](http://google.github.io/snappy/).## Build from sources
```shell
git clone --recursive --depth=1 https://github.com/kjdev/php-ext-snappy.git
cd php-ext-snappy
phpize
./configure
make
make install
```To use the system library
```shell
./configure --with-snappy-includedir=/usr
```## Distribution binary packages
### Fedora / CentOS / RHEL
RPM packages of this extension are available in [» Remi's RPM repository](https://rpms.remirepo.net/) and are named **php-snappy**.
## Configuration
php.ini:
```ini
extension=snappy.so
```### Function : `snappy_compress()`
string snappy_compress( string $data )
#### parameters
data:
The data to compress.
#### return values
The compressed string or FALSE if an error occurred.
### Function : `snappy_uncompress()`
string snappy_uncompress( string $data )
#### parameters
name:
The data compressed by snappy_compress().
#### return values
The original uncompressed data or FALSE on error.
## Example
```php
$compressed = snappy_compress('Compress me');$uncompressed = snappy_uncompress($compressed);
echo $uncompressed;
```## Troubleshooting
### Ubuntu / OSX
Snappy requires C++ and therefore might require for you to install the g++ or build-essential package.
If you get an error about "this file requires compiler and library support" or [compilation errors on OSX](https://github.com/kjdev/php-ext-snappy/issues/19), you need to enforce the compilation with `-std=c++11` flag:```shell
export CXXFLAGS=-std=c++11
phpize
./configure
make
```