• Stars
    star
    118
  • Rank 298,179 (Top 6 %)
  • Language
    C
  • Created about 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A high performance service tool for PHP

php扩展zqf (兼容php7)

    全局变量适用于高并发抢购、秒杀,红包生成,数组算法处理等,由于添加了二维码生成功能
    安装本扩展之前需要安装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
        如果没有安装libpng和libgd,也需要安装
        安装方法如下:
        sudo apt-get install libpng-dev
        sudo apt-get install libgd-dev
        致力于做工具类,其他的正在开发中
    zqf扩展安装(兼容php7)
    首先下载源码git clone https://github.com/qieangel2013/zqf.git或者composer安装
    然后cd到当前目录/usr/local/php/bin/phpize
    ./configure --with-php-config=/usr/local/php/bin/php-config
    make && make install
    make过程中如果出现
    error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘qrcode_png’
    /home/zqf-master/zqf.c: In function ‘zim_zqf_savefile’:
    /home/zqf-master/zqf.c:525: error: ‘gdImagePtr’ undeclared (first use in this function)
    /home/zqf-master/zqf.c:525: error: (Each undeclared identifier is reported only once
    /home/zqf-master/zqf.c:525: error: for each function it appears in.)
    /home/zqf-master/zqf.c:525: error: expected ‘;’ before ‘im’
    /home/zqf-master/zqf.c:571: error: ‘im’ undeclared (first use in this function)
    说明没有安装gd库
    yum install gd-devel
    然后重新make && make install
    修改php.ini添加extension=zqf.so
    重启php-fpm

===================================

红包生成算法(拼手气红包和普通红包)

        $obj=new zqf();
        第一个参数是红包总额,第二个人参数红包数量,第三个参数默认代表拼手气红包,设置为1的话为普通红包
        拼手气红包
        $hongb= $obj->hongbao(10,8);或者$hongb= $obj->hongbao(10,8,0);返回数组为Array ( [0] => 1.33 [1] => 1.02 [2] => 1.28 [3] => 0.44 [4] => 1.37 [5] => 0.81 [6] => 1.81 [7] => 1.94 )
        普通红包,每个人数额一样设置第三个参数
        $hongb= $obj->hongbao(10,8,1);返回数组为Array ( [0] => 1.25 [1] => 1.25 [2] => 1.25 [3] => 1.25 [4] => 1.25 [5] => 1.25 [6] => 1.25 [7] => 1.25 )
        var_dump($hongb);

高并发计数器使用方法如下:

        首先安装php扩展zqf.so
        phpize来安装
        然后在php文件调用
        dl('zqf.so');或者phpini里加载
        $obj=new zqf();
        $counter= $obj->autoadd(0,1,0);(声明只针对多线程)
        echo $counter;

数组快速排序使用方法如下:

        $asd=array(23,1,21,4,19,89,200,1,78,3,4,7,1,0,88);
        $obj=new zqf();
        $quick= $obj->quicksort($asd);
        print_r($quick);Array ( [0] => 0 [1] => 1 [2] => 1 [3] => 1 [4] => 3 [5] => 4 [6] => 4 [7] => 7 [8] => 19 [9] => 21 [10] => 23 [11] => 78 [12] => 88 [13] => 89 [14] => 200 )

查找数组重复元素使用方法如下:

        $arr=array(10,20,4,12,69,1,90,56,23,12,89,78);
        $obj=new zqf();
        $result= $obj->findrepetition($arr);查找$arr重复项算法
        var_dump($result);//结果是Array ( [3] => 12 [9] => 12 )

二分法查找数组元素使用方法如下:

        $arr=array(10,20,4,12,69,1,90,56,23,12,89,78);
        $obj=new zqf();
        $result= $obj->findval($arr,69);二分法快速查找$arr里的元素69,c底层会给数据进行排序
        var_dump($result);//结果是Array ( [8] => 69 [result] => Array ( [0] => 1 [1] => 4 [2] => 10 [3] => 12 [4] => 12 [5] => 20 [6] => 23 [7] => 56 [8] => 69 [9] => 78 [10] => 89 [11] => 90 ) )

二维码生成使用方法如下:

        $obj=new zqf();
        $obj->savefile('https://www.baidu.com/s?wd=昌平香堂','./test.png',500);第一个参数是url,第二参数是保存路径,第三个参数是二维码长或者宽
        生成透明二维码:
         $obj->savefile('https://www.baidu.com/s?wd=昌平香堂','./test.png',500,1);第四个参数默认不生成透明,要想生成透明得传一个参数
     生成带有logo的二维码:
     $obj->savefile('https://www.baidu.com/s?wd=昌平香堂','./test.png',500,0,"./logo.png");第五个参数是logo的路径,现在只支持png格式的logo图片

和phpqrcode对比

php-qrencode代码:
<?php
$t1 = microtime(true);
$obj=new zqf();
$obj->savefile('https://www.baidu.com/s?wd=昌平香堂','./test.png',500);
$t2 = microtime(true);
echo (($t2-$t1)*1000).':ms';
?>

运行时间:0.60701370239258:ms

phpqrcode代码:

<?php
include('./phpqrcode/phpqrcode.php'); 
$t1 = microtime(true);
QRcode::png("https://www.baidu.com/s?wd=昌平香堂",'./test.png',QR_ECLEVEL_Q,500);
$t2 = microtime(true);
echo (($t2-$t1)*1000).':ms';
?>
运行时间:23.189067840576:ms

项目地址

github:https://github.com/qieangel2013/zqf
oschina:https://gitee.com/qieangel2013/zqf

交流使用

交流群:337937322

如果你对我的辛勤劳动给予肯定,请给我捐赠,你的捐赠是我最大的动力

项目捐赠列表

More Repositories

1

zys

high performance service framework based on Yaf or Swoole
PHP
792
star
2

livego

go Implementation of live streaming services
Go
424
star
3

EsParser

PHP write SQL to convert DSL to query Elasticsearch
PHP
155
star
4

ngx-fastdfs

nginx + lua +fastdfs Real-time dynamic compression of distributed pictures
C
148
star
5

dfs

A distributed file server framework based on swoole and inotify
PHP
111
star
6

phpml

基于PHP-ML库实现机器学习
PHP
77
star
7

goMonitorLog

基于Aho-Corasick 算法+Trie树+DFA 来实现实时匹配,可以实时对文本过滤+字符过滤+敏感词过滤+关键词过滤+脏词过滤+多字符串匹配等处理 支持所有的文本文件类型(包括所有日志)
Go
29
star
8

zqfHB

统计php脚本文件运行时间的扩展
C
17
star
9

SmallAPP

WeChat applet demo
JavaScript
17
star
10

goMontioringDdl

go 通过binlog实现监控ddl发送钉钉报警
Go
17
star
11

zqf-cpp

A high performance service tool c++ for PHP
C++
14
star
12

ai

根据爬过来的数据进行清洗、调用word2vec实现智能分类
PHP
13
star
13

SqlReview

sql 去重、采样、解析、打分统计慢查询实现sql审核系统
Go
13
star
14

msecphp

基于腾讯开源的msec来进行php开发模块
PHP
13
star
15

phpword2vec

Php calls word2vec for machine learning
C
9
star
16

yaf-demo

yaf read write split mail cache
PHP
7
star
17

lua-nginx

nginx extension module lua
Lua
7
star
18

waf

waf 是一个基于lua-nginx-module(openresty)的web应用防火墙
Lua
7
star
19

cop

基于微信的libco实现php的协程扩展
C++
4
star
20

nginxLuaGmFastdfs

Nginx+Lua+Gm+Fastdfs可自动优化图片的图片服务
Lua
4
star
21

ns

程序员图书馆
Java
4
star
22

DCACHE

仿照配置中心的策略实现分布式删除yac缓存
Go
3
star
23

tcs-wzq

js html css 实现小游戏
HTML
3
star
24

hbase-parser

php的操作类库,通过写sql来来查询Hbase
PHP
3
star
25

ci-demo

ci读写分离
PHP
2
star
26

dms

python 协程实现数据迁移,可以跨库、同库之间迁移数据
Python
2
star
27

PythonChat

Python聊天室
Python
1
star
28

zqfcounter

并发最简单计数器
C
1
star
29

php_imagick_dpi

imagick把灰度图片转化为如果把图片以及php把图片转为dpi
PHP
1
star
30

smsService

基于gin和gorm实现的短信基础服务
Go
1
star