kjdev / php-ext-lz4 Goto Github PK
View Code? Open in Web Editor NEWLZ4 Extension for PHP
License: MIT License
LZ4 Extension for PHP
License: MIT License
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"
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
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.
Files lz4_encoder.h and lz4hc_encoder.h are no longer useful, and could be removed
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?
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 am not sure if this should be an issue or if it is intended behavior.
The lz4 frames produced by this extension do not have the expected lz4 magic number and are therefore incompatible with the lz4 software.
I think it would be worthwhile submitting this to PECL
Hi Kamijo
There is a new security fix for 32-bits system available at :
https://github.com/Cyan4973/lz4/releases/latest
The issue affects programs accepting very large data blocks in 32-bits mode.
As a security measure, all binders are invited to upgrade their underlying C source code to latest version.
Regards
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
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);
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
make: *** No rule to make target /opt/php-ext-lz4-0.3.5/lz4/lib/lz4.c', needed by
lz4/lib/lz4.lo'. Stop.
Is there a dll for this?
In 010.phpt used function hex2bin which appears only since php-5.4.
You should use replacement for it as defined here: http://php.net/manual/ru/function.hex2bin.php#113057
Or skip test if php version less than 5.4.0.
Hi,
Your library is under the PHP License which is very specific to PHP itself. This license is not usable for anything else. Can you relicense (if you own copyright)?
See also point 3 of http://ftp-master.debian.org/REJECT-FAQ.html
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 .
Anything on the roadmap here?
Would you please provide dll for this.
I interest use php-ext-lz4 on windows/iis environment.
Compiling on windows does not work when done using the lz4 library source code. This can probably be fixed by producing the proper nmake makefiles for it. A quicker workaround is to compile the liblz4 visual studio project, take the produced library liblz4_static.lib rename it to liblz4.lib and put it in the folder:
<php source root>\no\lib\
Also copy the header files lz4.h and lz4hc.h to the folder
<php source root>\no\include\
If the desired outcome is an extension dll edit config.w32 in the lz4 extension folder and replace the EXTENSION lines with:
EXTENSION("lz4", "lz4.c", true, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
This last step is only necessary if someone like myself does not know how to get the PHP_LZ4_SHARED variable to have true as a value and a dll is preferred to a monolitic php build.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.