Giter Club home page Giter Club logo

php-ext-zstd's Introduction

Zstd Extension for PHP

Linux Windows

This extension allows Zstandard.

Documentation for Zstandard can be found at » https://github.com/facebook/zstd.

Build from sources

% git clone --recursive --depth=1 https://github.com/kjdev/php-ext-zstd.git
% phpize
% ./configure
% make
% make install

To use the system library

% ./configure --with-libzstd

Install from pecl:

% pecl install zstd

Distribution binary packages

Fedora

Fedora users can install the » php-zstd package from official repository.

dnf install php-zstd

CentOS / RHEL

CentOS / RHEL (and other clones) users can install the » php-zstd package from » EPEL repository.

yum install php-zstd

Other RPM packages of this extension, for other PHP versions, are available in » Remi's RPM repository.

Configration

php.ini:

extension=zstd.so

Constant

Name Description
ZSTD_COMPRESS_LEVEL_MIN Minimal compress level value
ZSTD_COMPRESS_LEVEL_MAX Maximal compress level value
ZSTD_COMPRESS_LEVEL_DEFAULT Default compress level value
LIBZSTD_VERSION_NUMBER libzstd version number
LIBZSTD_VERSION_STRING libzstd version string

Function

  • zstd_compress — Zstandard compression
  • zstd_uncompress — Zstandard decompression
  • zstd_compress_dict — Zstandard compression using a digested dictionary
  • zstd_uncompress_dict — Zstandard decompression using a digested dictionary

zstd_compress — Zstandard compression

Description

string zstd_compress ( string $data [, int $level = 3 ] )

Zstandard compression.

Pameters

  • data

    The string to compress.

  • level

    The level of compression (1-22). (Defaults to 3, 0 for no compression)

    A value smaller than 0 means a faster compression level. (Zstandard library 1.3.4 or later)

Return Values

Returns the compressed data or FALSE if an error occurred.

zstd_uncompress — Zstandard decompression

Description

string zstd_uncompress ( string $data )

Zstandard decompression.

Alias: zstd_decompress

Pameters

  • data

    The compressed string.

Return Values

Returns the decompressed data or FALSE if an error occurred.

zstd_compress_dict — Zstandard compression using a digested dictionary

Description

string zstd_compress_dict ( string $data , string $dict )

Zstandard compression using a digested dictionary.

Alias: zstd_compress_usingcdict

Pameters

  • data

    The string to compress.

  • dict

    The Dictionary data.

Return Values

Returns the compressed data or FALSE if an error occurred.

zstd_uncompress_dict — Zstandard decompression using a digested dictionary

Description

string zstd_uncompress_dict ( string $data , string $dict )

Zstandard decompression using a digested dictionary.

Alias: zstd_decompress_dict, zstd_uncompress_usingcdict, zstd_decompress_usingcdict

Pameters

  • data

    The compressed string.

  • dict

    The Dictionary data.

Return Values

Returns the decompressed data or FALSE if an error occurred.

Namespace

Namespace Zstd;

function compress( $data [, $level = 3 ] )
function uncompress( $data )
function compress_dict ( $data, $dict )
function uncompress_dict ( $data, $dict )

zstd_compress, zstd_uncompress, zstd_compress_dict and zstd_uncompress_dict function alias.

Streams

Zstd compression and uncompression are available using the compress.zstd:// stream prefix.

Examples

// Using functions
$data = zstd_compress('test');
zstd_uncompress($data);

// Using namespaced functions
$data = \Zstd\compress('test');
\Zstd\uncompress($data);

// Using streams
file_put_contents("compress.zstd:///patch/to/data.zstd", $data);
readfile("compress.zstd:///patch/to/data.zstd");

php-ext-zstd's People

Contributors

cmb69 avatar dariuskasiulevicius avatar fedotov-as avatar glensc avatar kjdev avatar martinml avatar nobuf avatar remicollet avatar sergey-dryabzhinsky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.