{"id":26707982,"url":"https://github.com/qieangel2013/yaf","last_synced_at":"2025-03-27T07:01:57.871Z","repository":{"id":36762804,"uuid":"41069485","full_name":"qieangel2013/zys","owner":"qieangel2013","description":"high performance service framework based on Yaf or Swoole","archived":false,"fork":false,"pushed_at":"2018-02-05T09:09:40.000Z","size":4614,"stargazers_count":791,"open_issues_count":0,"forks_count":255,"subscribers_count":98,"default_branch":"master","last_synced_at":"2024-10-13T21:02:13.985Z","etag":null,"topics":["hprose","liveim","php","swoole","thrift","yaconf","yaf","zqf","zys"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qieangel2013.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-20T01:54:50.000Z","updated_at":"2024-07-10T05:45:08.000Z","dependencies_parsed_at":"2022-08-24T05:00:22.212Z","dependency_job_id":null,"html_url":"https://github.com/qieangel2013/zys","commit_stats":null,"previous_names":["qieangel2013/yaf"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qieangel2013%2Fzys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qieangel2013%2Fzys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qieangel2013%2Fzys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qieangel2013%2Fzys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qieangel2013","download_url":"https://codeload.github.com/qieangel2013/zys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245798587,"owners_count":20673902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hprose","liveim","php","swoole","thrift","yaconf","yaf","zqf","zys"],"created_at":"2025-03-27T07:01:56.503Z","updated_at":"2025-03-27T07:01:57.863Z","avatar_url":"https://github.com/qieangel2013.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# zys高性能服务框架\n[![Build Status](https://api.travis-ci.org/qieangel2013/zys.svg)](https://travis-ci.org/qieangel2013/zys)\n[![Packagist](https://img.shields.io/badge/packagist-passing-ff69b4.svg)](https://packagist.org/packages/qieangel2013/zys)\n![Supported PHP versions: \u003e=5.5](https://img.shields.io/badge/php-%3E%3D5.5-blue.svg)\n![License](https://img.shields.io/badge/license-Apache%202-yellow.svg)\n### 核心特性\n\t1.基于swoole提供分布式服务器通讯服务\n\t2.基于thrift提供rpc远程调用服务\n\t3.基于HTML5提供在线网络直播平台服务\n\t4.基于swoole提供同步异步数据库连接池服务\n\t5.基于swoole提供异步任务服务器投递任务服务\n\t6.基于vmstat提供服务器硬件实时监控服务\n\t7.基于yac、yaconf提供共享数据、配置服务\n\t8.基于zqf提供高并发计数器、红包、二维码服务\n\t9.很好的支持网页版console的shell服务\n\t10.基于hprose提供rpc远程调用、推送等服务\n\t11.基于zqfHB的php扩展统计php脚本执行时间的服务\n\t12.支持命名空间、thinkphp5的ORM和部分工具类\n\t13.全新多进程同步数据库连接池支持高并发，响应迅速\n### Nginx 下配置\n\tlocation / {\n        if (!-e $request_filename) {\n           rewrite ^/(.*)$ /index.php?$1 last;\n        }\n    }\n### 服务启动\n\t需要php以cli模式运行/server/server.php\n        php server.php start\n        php server.php stop\n        php server.php restart\n### mysql同步多进程数据库连接池\n\t新增mysql同步多进程数据库连接池\n\t采用redis存储未及时处理的sql，针对多进程并发采用排他锁控制\n\t能够自动扩容mysql客户端，根据需要自己修改，当mysql客户端处理不过来会触发扩容机制\n\t实时捕获运行中的错误，会及时返回给用户，针对执行错或者sql错误都会记录日志并且把sql书写错误的会返回给用户\n\t使用方法：\n\t$data=querysql('select * from user');//注意：querysql是全局函数，只能在apache/php-fpm下使用\n\tvar_dump($data);\n\t注意：如果服务器性能好一些，建议对https://github.com/qieangel2013/zys/blob/master/server/swoole/MySQLPollServer.php\n\t这个文件里的poolsize_max和dilatationpool_max适当的调大一些，这样高并发下执行会很快，如果数据库配置特别差，\n\t建议按默认的参数走\n### composer 安装\n\t{\n    \t\t\"require\": {\n        \t\t\"qieangel2013/zys\": \"2.0.0.1\"\n\t\t}\n\t}\n### 后台admin\n\t后台admin访问http://www.51bixue.com:88/admin/user/index\n### 分布式服务器通讯服务\n\t建立多个服务器之间进行数据通信服务，服务自动连接在线服务器，支持热拔，启动服务后自动连接，无需人为干预\n\t注意事项：\n\t\t需要在conf/application.conf里配置端口和监听、日志等\n\t\t需要有一个redis服务器，并且分布式服务器都能连接redis\n\t\tweb端可以直接调用服务\n\t\t使用如下\n\t\t//注意：type为sql、file，要是需要别的功能，自己定义\n        \tif($_FILES){\n        \t//数据同步\n        \t$sql = array('type'=\u003e'sql','data'=\u003e'show tables');\n        \tvar_dump(distributed::getInstance()-\u003equery($sql));\n        \t//文件同步（不用安装rsync+inotify就可以实现文件同步，并且是触发式的占用很小的资源，调用sendfile零复制）\n            \t$dir_pre=MYPATH.'/public/uploads/';\n            \tif(!is_dir($dir_pre.date('Ymd'))){\n                \tmkdir($dir_pre.date('Ymd'),0777,true);\n        \t }\n            \tif(is_uploaded_file($_FILES['file']['tmp_name'])){ \n                $upname=explode('.',$_FILES['file']['name']);\n                $filename=uniqid().substr(time(),-4).'.'.$upname[1];\n                if(move_uploaded_file($_FILES['file']['tmp_name'],$dir_pre.date('Ymd').'/'.$filename)){  \n                    echo \"Stored in: \" . $dir_pre.date('Ymd').'/'.$filename; \n                    $fileinfo = array('type'=\u003e'file','data'=\u003earray('path' =\u003e'/public/uploads/'.date('Ymd').'/'.$filename,'size'=\u003e$_FILES['file']['size'],'ext'=\u003e$upname[1]));\n                    var_dump(distributed::getInstance()-\u003equeryfile($fileinfo));\n                \t}else{  \n                    \techo 'Stored failed:file save error';  \n                \t}  \n            \t}else{\n                echo 'Stored failed:no post ';  \n            }\n       \t}\n       \t\t本地访问：http:/localhost/index/distributed/\n       \t\t架构图\n![](https://github.com/qieangel2013/yaf/blob/master/public/images/jg.png)\n       \t\t执行结果如下\n![](https://github.com/qieangel2013/yaf/blob/master/public/images/dis1.png)![](https://github.com/qieangel2013/yaf/blob/master/public/images/dis2.png)\n### thrift的rpc远程调用\n\t本地访问http://localhost/index/rpc （返回0表示成功）\n### 数据库连接池使用方法\n\t服务文件在/server/mysql/DbServer.php\n\t简单地封装文件在/application/library/mysql/dbclient.php\n\t配置在conf/application.ini中\n\t;数据库连接池配置\n\tDbServer.async=true   //配置是同步执行还是异步执行，默认不配置代表异步执行，同步执行设置为false\n\tDbServer.multiprocess=false //配置是否启用多进程，默认不配置代表单进程阻塞模式，多进程模式要设置为true\n\tDbServer.pool_num=20  //配置连接池mysql的数量\n\tDbServer.port=9501\n\tDbServer.logfile=\"/server/log/DbServer.log\"\n\tDbServer.localip=\"192.168.2.13\"\n\t使用方法：\n\t$dbclient=new mysql_dbclient;\n        //print_r($data);\n        for ($i=0; $i \u003c100 ; $i++) { \n            $dbclient-\u003equery(\"INSERT INTO user(name) VALUES('$i')\");\n            //echo \"INSERT INTO user(name) VALUES('$i')\";\n        }\n        $data=$dbclient-\u003equery(\"select * from user\");\n        $dbclient-\u003eclose();\n        print_r($data);\n        exit;\n        本地访问：http:/localhost/index/dbtest/\n### 数据库连接池多进程执行如下\n![](https://github.com/qieangel2013/yaf/blob/master/public/images/multiprocess.png)\n### swoole实现简单的视频直播（可以实时传音频、视频、聊天）\n\t录制视频页面 http://localhost/index/swoolelivecamera\n\t接受视频页面 http://localhost/index/swoolelive\n\t采用vue+html5实现的聊天ui界面\nhttp://www.jduxiu.com:88/live/index/index (演示地址)\n![](https://github.com/qieangel2013/yaf/blob/master/public/images/testlive.png)\n### liveim是一款直播平台，内置im聊天功能\n\t由于未开源，需要授权可以获取源代码\nhttp://www.weivq.com:88/ (演示地址)\u003cbr/\u003e\nhttp://www.weivq.com:88/public/uploads/LiveIm.apk (安卓演示)\u003cbr/\u003e\nhttp://www.weivq.com:88/public/uploads/LiveImInstall.exe (pc端演示)\n![](https://github.com/qieangel2013/yaf/blob/master/public/images/windowspc.png)\n![](https://github.com/qieangel2013/yaf/blob/master/public/images/jt.png)\n![](https://github.com/qieangel2013/yaf/blob/master/public/images/jtmobilet.png)\n### vmstat服务器监控\n\t本地访问http://localhost/vmstat/\n\t执行如下：\n![](https://github.com/qieangel2013/yaf/blob/master/public/images/vmstats.png)\n### yac、yaconf提供共享数据、配置使用如下\n\t需要安装php扩展yac、yaconf\n\t//注意：需要安装yaconf扩展，并且yaconf.directory=/tmp/yaconf 必须在php.ini里设置，不能动态加载\n        echo Yaconf::get(\"conf.zqf\");\n        //注意：需要安装yac扩展，用于存储共享变量，下面的实例作为高并发计数器\n        $yac = new Yac();\n        $count=$yac-\u003eget('zqf');\n        if(!$count){\n            $yac-\u003eset('zqf', 1);\n        }else{\n            $yac-\u003eset('zqf', $count+0.5);\n        }\n        echo $count;\n### 高并发计数器、红包、二维码使用如下\n\t需要安装php扩展zqf\n\t首先安装php扩展zqf.so\n\tphpize来安装\n\t然后在php文件调用\n\tdl('zqf.so');或者phpini里加载（[项目地址](https://github.com/qieangel2013/zqf)）\n\t$obj=new zqf();\n\t$counter= $obj-\u003eautoadd(0,1,0);（声明只针对多线程）\n\techo $counter;\n\t红包第一个参数是红包总额，第二个人参数红包数量，第三个参数默认代表拼手气红包，设置为1的话为普通红包\n\t拼手气红包\n\t$hongb= $obj-\u003ehongbao(10,8);或者$hongb= $obj-\u003ehongbao(10,8,0);返回数组为Array ( [0] =\u003e 1.33 [1] =\u003e 1.02 [2] =\u003e 1.28 [3] =\u003e 0.44 [4] =\u003e 1.37 [5] =\u003e 0.81 [6] =\u003e 1.81 [7] =\u003e 1.94 )\n\t普通红包，每个人数额一样设置第三个参数\n\t$hongb= $obj-\u003ehongbao(10,8,1);返回数组为Array ( [0] =\u003e 1.25 [1] =\u003e 1.25 [2] =\u003e 1.25 [3] =\u003e 1.25 [4] =\u003e 1.25 [5] =\u003e 1.25 [6] =\u003e 1.25 [7] =\u003e 1.25 )\n\tvar_dump($hongb);\n\t$obj-\u003esavefile('https://www.baidu.com/s?wd=昌平香堂','./test.png',500);第一个参数是url，第二参数是保存路径，第三个参数是二维码长或者宽\n\t$obj-\u003esavefile('https://www.baidu.com/s?wd=昌平香堂','./test.png',500,1);第一个参数是url，第二参数是保存路径，第三个参数是二维码长或者宽，第四个参数是决定是否透明，默认是不透明的\n### php脚本执行时间统计扩展\n\twget https://github.com/redis/hiredis/archive/v0.13.3.tar.gz\n\ttar zxvf v0.13.3.tar.gz\n\tcd hiredis-0.13.3\n\tmake\n\tmake install\n\t如果出现libhiredis.so.0.13: cannot open shared object file: No such file or directory in Unknown on line 0\n\tvi /etc/ld.so.conf\n\t文件末尾添加  /usr/local/lib\n\t然后执行ldconfig\n\t./phpize（[项目地址](https://github.com/qieangel2013/zqfHB)）\n\t./configure --with-php-config=/usr/local/php/bin/php-config\n\tmake\n\tmake install\n\tadd zqfHB.so to php.ini\n\textension=zqfHB.so\n\t[zqfHB]\n\tzqfHB.slow_maxtime=10000(单位微妙1s=1000000us,改参数是页面加载超过这个时间会统计)\n\tzqfHB.type=1（1代表redis 2代表memcache，由于memcache性能处理有点低，暂时不开放）\n\tzqfHB.auth=123456(如果redis没有密码，此项不必配置，如果有密码，必须配置此项)\n\tzqfHB.host=192.168.102.163\n\tzqfHB.port=6379\n\t使用：\n\t把web里的所有文件复制到网站目录下或者放在其他目录下\n\t直接执行http://localhost/web/\n\t效果图：\n![](https://github.com/qieangel2013/zqfHB/blob/master/images/img1.png)\n![](https://github.com/qieangel2013/zqfHB/blob/master/images/img2.png)\n### 网页版console的shell使用如下\n\t本地访问http://localhost/console/console.php\n### hprose的使用如下\n\techo hprose::getInstance()-\u003egetdata();\n\t本地访问：http://localhost/index/hprose\n### 交流使用\n\tzys框架交流群：337937322\n### License\n\nApache License Version 2.0 see http://www.apache.org/licenses/LICENSE-2.0.html\n### 如果你对我的辛勤劳动给予肯定，请给我捐赠，你的捐赠是我最大的动力\n![](https://github.com/qieangel2013/zys/blob/master/public/images/pw.jpg)\n![](https://github.com/qieangel2013/zys/blob/master/public/images/pay.png)\n[项目捐赠列表](https://github.com/qieangel2013/zys/wiki/%E9%A1%B9%E7%9B%AE%E6%8D%90%E8%B5%A0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqieangel2013%2Fyaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqieangel2013%2Fyaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqieangel2013%2Fyaf/lists"}