Git Product home page Git Product logo

php-ext-lz4's Introduction

LZ4 Extension for PHP

Linux Windows

This extension allows LZ4.

Documentation for LZ4 can be found at » https://github.com/Cyan4973/lz4.

Build from sources

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

To use the system library

% ./configure --with-lz4-includedir=/usr

Distribution binary packages

Fedora / CentOS / RHEL

RPM packages of this extension are available in » Remi's RPM repository and are named php-lz4.

Debian

DEB packages of this extension are available in » Ondřej Surý's DEB repository and are named php-lz4.

Configuration

php.ini:

extension=lz4.so

Function

  • lz4_compress — LZ4 compression
  • lz4_uncompress — LZ4 decompression

lz4_compress — LZ4 compression

Description

string lz4_compress ( string $data [ , int $level = 0 , string $extra = NULL ] )

LZ4 compression.

Pameters

  • data

    The string to compress.

  • level

    The level of compression (1-12, Recommended values are between 4 and 9). (Default to 0, Not High Compression Mode.)

  • extra

    Prefix to compressed data.

Return Values

Returns the compressed data or FALSE if an error occurred.

lz4_uncompress — LZ4 decompression

Description

string lz4_uncompress ( string $data [ , long $maxsize = -1 , long $offset = -1 ] )

LZ4 decompression.

Pameters

  • data

    The compressed string.

  • maxsize

    Allocate size output data.

  • offset

    Offset to decompressed data.

Return Values

Returns the decompressed data or FALSE if an error occurred.

Examples

$data = lz4_compress('test');

lz4_uncompress($data);

Compress Data

Default

$data = lz4_compress('test')

compress-default

Extra prefix data

$data = lz4_compress('test', false, 'PREFIX')

compress-extra

Uncompress Data

Default

lz4_uncompress($data);

uncompress-default

Offset

lz4_uncompress($data, 256, 6);

uncompress-offset

php-ext-lz4's People

Contributors

jan-e avatar kirbyde avatar kjdev avatar remicollet avatar sergey-dryabzhinsky avatar xon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-ext-lz4's Issues

/usr/local/src/php-ext-lz4/lz4.c:35:17: fatal error: lz4.h: No such file or directory

Compilation on Ubuntu 16.04.

root@web:/usr/local/src# git clone https://github.com/kjdev/php-ext-lz4
Cloning into 'php-ext-lz4'...
remote: Counting objects: 247, done.
remote: Total 247 (delta 0), reused 0 (delta 0), pack-reused 247
Receiving objects: 100% (247/247), 211.61 KiB | 0 bytes/s, done.
Resolving deltas: 100% (132/132), done.
Checking connectivity... done.
root@web:/usr/local/src# cd php-ext-lz4
root@web:/usr/local/src/php-ext-lz4# make clean
make: *** No rule to make target 'clean'.  Stop.
root@web:/usr/local/src/php-ext-lz4# phpize7.0 && ./configure && make && make install
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20151012
checking for PHP installed headers prefix... /usr/include/php/20151012
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking PHP version... #define PHP_VERSION "7.0.12-1+deb.sury.org~xenial+1"
./configure: line 3892: test: too many arguments
checking whether to enable lz4 support... yes, shared
checking for lz4 header... no
checking searching for liblz4... use bundled version
checking whether to enable coverage support... no
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) gawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
/bin/bash /usr/local/src/php-ext-lz4/libtool --mode=compile cc  -I. -I/usr/local/src/php-ext-lz4 -DPHP_ATOM_INC -I/usr/local/src/php-ext-lz4/include -I/usr/local/src/php-ext-lz4/main -I/usr/local/src/php-ext-lz4 -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -I/usr/local/src/php-ext-lz4/lz4/lib  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/php-ext-lz4/lz4.c -o lz4.lo 
libtool: compile:  cc -I. -I/usr/local/src/php-ext-lz4 -DPHP_ATOM_INC -I/usr/local/src/php-ext-lz4/include -I/usr/local/src/php-ext-lz4/main -I/usr/local/src/php-ext-lz4 -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -I/usr/local/src/php-ext-lz4/lz4/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/php-ext-lz4/lz4.c  -fPIC -DPIC -o .libs/lz4.o
/usr/local/src/php-ext-lz4/lz4.c:35:17: fatal error: lz4.h: No such file or directory
compilation terminated.
Makefile:193: recipe for target 'lz4.lo' failed
make: *** [lz4.lo] Error 1

php unexpected exiting when uncompress the wrong format data

The code for reproducing issue:

$json_output = base64_decode('{"header":{"code":2003004,"exe_time":"0.0135","info":"product not exist","desc":"Productdoes not exist.","template":{"message":""},"debug":{"file":"/home/work/data/www/shopapi.xiaomi.com/server/api/model/ShoppingModel.php","line":734},"compress":"lz4compress.1"},"body":[],"times":{"redis":{"shopapi_misc":{"conn":["0.0022"],"read":["0.0015","0.0011"]},"pms_cart":{"conn":["0.0006"],"read":["0.0013"]}}}}"');

var_dump($json_output);

$json_output = lz4_uncompress($json_output);

v0.4.2 - unused variables treated like errors

OS: Ubuntu 14.04
Compiler: gcc-4.8
PHP: any version

Build errors:

/home/sergey/debuild-php/modules/php-mod-lz4/php-mod-lz4-0.4.2/src/lz4.c: In function ‘zif_lz4_compress’:
/home/sergey/debuild-php/modules/php-mod-lz4/php-mod-lz4-0.4.2/src/lz4.c:295:9: error: unused variable ‘offset’ [-Werror=unused-variable]
     int offset = 0;
         ^
/home/sergey/debuild-php/modules/php-mod-lz4/php-mod-lz4-0.4.2/src/lz4.c:288:10: error: unused variable ‘maxLevel’ [-Werror=unused-variable]
     long maxLevel = (long)PHP_LZ4_CLEVEL_MAX;
          ^
/home/sergey/debuild-php/modules/php-mod-lz4/php-mod-lz4-0.4.2/src/lz4.c:286:31: error: unused variable ‘dst_len’ [-Werror=unused-variable]
     int output_len, data_len, dst_len;
                               ^
/home/sergey/debuild-php/modules/php-mod-lz4/php-mod-lz4-0.4.2/src/lz4.c:286:21: error: unused variable ‘data_len’ [-Werror=unused-variable]
     int output_len, data_len, dst_len;
                     ^
/home/sergey/debuild-php/modules/php-mod-lz4/php-mod-lz4-0.4.2/src/lz4.c: In function ‘zif_lz4_uncompress’:
/home/sergey/debuild-php/modules/php-mod-lz4/php-mod-lz4-0.4.2/src/lz4.c:327:21: error: unused variable ‘data_size’ [-Werror=unused-variable]
     int output_len, data_size;
                     ^
cc1: all warnings being treated as errors

I can not find phpize or configure

When following the build instructions. I did not find phpize or configure files.
I found also that I can not compile it through make as the make file is in .gitignore file.

Thanks for your help.

uncompressed data to lz uncompress fuunction

if uncompressed data is passed to lz uncompress function , it return nothing

so it will be good if uncompress data like say 1234 is passed it return same 1234 because its not compressed.
for that i think we should add prefix parameter to uncompress function , but default lzcompress function i think user @ as prefix so if uncompress function cant find @ or any other prefix passed to it in data then it should return same input which i passed to it

thanks

uncompressing with prefix failed

if we compress data with prefix set and high compression mode set then uncompress failed
example

$data = lz4_compress("test string of lz4",true,'@w3');
lz4_uncompress($data);     // uncompress failed .

lz4 on windows

Would you please provide dll for this.
I interest use php-ext-lz4 on windows/iis environment.

php 5.6 support ?

I'm using php 5.6.x not 5.5.x
It's not seem to be supported php 5.6.x

root@ecommerce:/usr/local/src/xdebug-2.3.2# php -v
PHP Warning:  PHP Startup: lz4: Unable to initialize module
Module compiled with module API=20121212
PHP    compiled with module API=20131226
These options need to match
 in Unknown on line 0
PHP 5.6.7-1+deb.sury.org~trusty+1 (cli) (built: Mar 24 2015 11:21:10) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans

useless source files

Files lz4_encoder.h and lz4hc_encoder.h are no longer useful, and could be removed

lz4.c:35:17

php-ext-lz4-0.3.5/lz4.c:35:17: fatal error: lz4.h: No such file or directory
#include "lz4.h"
#include "lz4hc.h"

No rule to make target

Hi @kjdev,

I am trying to integrate php-ext-lz4 into the official docker 8.1 php-fpm image. However, I get the following error message:

creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
+ make
/bin/bash /tmp/php-ext-lz4-0.4.3/libtool --mode=compile cc -I. -I/tmp/php-ext-lz4-0.4.3 -I/tmp/php-ext-lz4-0.4.3/include -I/tmp/php-ext-lz4-0.4.3/main -I/tmp/php-ext-lz4-0.4.3 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/php-ext-lz4-0.4.3/lz4/lib  -DHAVE_CONFIG_H      -DZEND_COMPILE_DL_EXT=1 -c /tmp/php-ext-lz4-0.4.3/lz4.c -o lz4.lo  -MMD -MF lz4.dep -MT lz4.lo
mkdir .libs
 cc -I. -I/tmp/php-ext-lz4-0.4.3 -I/tmp/php-ext-lz4-0.4.3/include -I/tmp/php-ext-lz4-0.4.3/main -I/tmp/php-ext-lz4-0.4.3 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/php-ext-lz4-0.4.3/lz4/lib -DHAVE_CONFIG_H -DZEND_COMPILE_DL_EXT=1 -c /tmp/php-ext-lz4-0.4.3/lz4.c -MMD -MF lz4.dep -MT lz4.lo  -fPIC -DPIC -o .libs/lz4.o
make: *** No rule to make target '/tmp/php-ext-lz4-0.4.3/lz4/lib/lz4.c', needed by 'lz4/lib/lz4.lo'.  Stop.

Here is the relevant part from my Dockerfile:

	curl -L 'https://github.com/kjdev/php-ext-lz4/archive/refs/tags/0.4.3.tar.gz' | \
		tar xvz -C /tmp; \
	( \
		cd /tmp/php-ext-lz4-0.4.3; \
		phpize; \
		./configure; \
		make; \
		make install \
	); \
	rm -r /tmp/php-ext-lz4-0.4.3; \

Any idea how to fix this error?

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.