Giter VIP home page Giter VIP logo

php-qrencode's Introduction

php-qrencode

基于libqrencode+libgd的生成二维码的php扩展

安装:

1,安装libpng & libjpg

sudo apt-get install libpng-dev
sudo apt-get install libjpeg-dev

2,安装libqrencode

wget http://fukuchi.org/works/qrencode/qrencode-3.4.4.tar.gz
tar zxvf qrencode-3.4.4.tar.gz
cd qrencode-3.4.4/
./configure
make&make install

3,安装libgd

sudo apt-get install libgd-dev

4,安装php-qrencode

git clone https://github.com/Leon2012/php-qrencode
cd php-qrencode
phpize
./configure
make&sudo make install

5,修改配置文件

vi php.ini
extension=qrencode.so

用法:

<?php
$resource = qrencode_create("test", 2, 2);
if (!is_null($resource)){
	//qrencode_save($resource, "./test.png");//保存文件
	qrencode_output($resource);//直接输出到浏览器
}
echo qrencode_version()."\n";//查看版本号

?>

和phpqrcode对比

php-qrencode代码:

<?php
$t1 = microtime(true);
$qrcode_image = "/Users/kentchen/Downloads/qrencode1.png";
$content = "hello world";
$resource = qrencode_create($content, QRENCODE_QRECLEVEL_Q, QRENCODE_MODE_8);
qrencode_save($resource, $qrcode_image);
$t2 = microtime(true);
echo (($t2-$t1)*1000).':ms';
?>

运行时间:0.60701370239258:ms

phpqrcode代码:

<?php
include('./phpqrcode/phpqrcode.php'); 
$t1 = microtime(true);
$qrcode_image = "/Users/kentchen/Downloads/qrencode2.png";
$content = "hello world";
QRcode::png($content, $qrcode_image, QR_ECLEVEL_Q, 12);
$t2 = microtime(true);
echo (($t2-$t1)*1000).':ms';
?>

运行时间:23.189067840576:ms

php-qrencode's People

Contributors

leon2012 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

php-qrencode's Issues

when call qrencode_save,return 502 bad gateway

$qrcode_image = "/tmp/qrencode1.png";
$content = "hello world";
try{
$resource = qrencode_create($content, 2, 2);

qrencode_save($resource, $qrcode_image);

}catch(Exception $e){
print_r($e->getMessage());
}

i don't know why

Support PHP 7

Hi, I tried on PHP 7.0.1, but I had below error.

$ phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012

$ make
...
php-qrencode/qrencode.c:142:27: error: unknown type name 'zend_rsrc_list_entry'
static void qrencode_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
                          ^
php-qrencode/qrencode.c:235:41: error: too many arguments provided to function-like macro invocation
    RETURN_STRING(PHP_QRENCODE_VERSION, 1);
                                        ^
php70/7.0.1/include/php/Zend/zend_API.h:637:9: note: macro 'RETURN_STRING' defined here
#define RETURN_STRING(s)                                { RETVAL_STRING(s); return; }
        ^
php-qrencode/qrencode.c:235:5: error: use of undeclared identifier 'RETURN_STRING'
    RETURN_STRING(PHP_QRENCODE_VERSION, 1);
    ^
php-qrencode/qrencode.c:280:5: warning: implicit declaration of function 'ZEND_REGISTER_RESOURCE' is
      invalid in C99 [-Wimplicit-function-declaration]
    ZEND_REGISTER_RESOURCE(return_value, qe, le_qrencode);
    ^
php-qrencode/qrencode.c:319:5: warning: implicit declaration of function 'ZEND_FETCH_RESOURCE' is
      invalid in C99 [-Wimplicit-function-declaration]
    ZEND_FETCH_RESOURCE(qe, qrencode*, &zqe, -1, QRENCODE_RESOURCE_TYPE, le_qrencode);
    ^
php-qrencode/qrencode.c:319:29: error: unexpected type name 'qrencode': expected expression
    ZEND_FETCH_RESOURCE(qe, qrencode*, &zqe, -1, QRENCODE_RESOURCE_TYPE, le_qrencode);
                            ^
php-qrencode/qrencode.c:319:38: error: expected expression
    ZEND_FETCH_RESOURCE(qe, qrencode*, &zqe, -1, QRENCODE_RESOURCE_TYPE, le_qrencode);
                                     ^
php-qrencode/qrencode.c:391:29: error: unexpected type name 'qrencode': expected expression
    ZEND_FETCH_RESOURCE(qe, qrencode*, &zqe, -1, QRENCODE_RESOURCE_TYPE, le_qrencode);
                            ^
php-qrencode/qrencode.c:391:38: error: expected expression
    ZEND_FETCH_RESOURCE(qe, qrencode*, &zqe, -1, QRENCODE_RESOURCE_TYPE, le_qrencode);
                                     ^
php-qrencode/qrencode.c:409:5: warning: implicit declaration of function 'php_gd_gdImagePngCtxEx' is
      invalid in C99 [-Wimplicit-function-declaration]
    gdImagePngCtxEx(im, ctx, -1)

Thanks

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.