Giter Club home page Giter Club logo

zhttp's Introduction

zhttp-根据zphp改造专门用来做http服务的轻量级框架

(当前只用来做app接口用)

注意事项

1.框架最新加入协程+mysql连接池,非阻塞的mysql查询大大提高了框架应对请求的吞吐量
2.php版本需要7.0+
3.swoole版本1.8.*

##运行demo

本框架只支持http模式:
运行:
cd webroot;
php main.php start|stop|restart|reload
访问IP:PORT
建议:
	如果是静态文件,可以直接用nginx代理
	如果是动态请求,最好使用nginx做代理转发

###目录结构 目录结构

####apps - mvc框架的controllers和service

^ service 通常的调用服务层

####config - 配置文件 ####library - 对应的全局函数,每个work进程启动的时候会加载这个方法

###路由 根据pathinfo访问对应得controller,如ip:port/home/index/index则会访问home目录下的IndexController的index方法;如果不指定pathinfo则访问home目录下的IndexController的index方法

###Cache-redis(已经是异步非阻塞) 配置:

return [
    'redis'=>[
        'ip' => 'localhost',
        'port' => 6379,
        'select' => 0,
        'password' => '',
        'asyn_max_count' => 10,
    ]
];

使用:

$data = yield Db::redis()->cache('abcd');

只要在config目录下配置cache文件,即可在业务里调用缓存方法,如:

##数据库 ###mysql(已经是异步非阻塞) 在config下配置mysql的配置文件,即可在业务中使用,你可以使用以下方法查询数据

 		$data = Db::table()->query('select* from admin_user');
        $a = DB::table()->query('select*from admin_user where id =1');
        $userinfo = table('admin_user')->where(['id'=>1])->find();

###http client(已经是异步非阻塞)

$httpClient = new HttpClientCoroutine();
$data = yield $httpClient->request('http://speak.test.com/');

###框架全部封装好.怎么样,这异步用起来是不是很简单^_^

###mongo(还是同步阻塞的) 在config下配置mongo的配置文件,即可在业务中使用,如下

$data = Db::collection('stu_quest_score')->findOne(['iStuId'=>26753]);

##ab测试-本机裸跑输出 本机裸跑输出

##ab测试-本机查询mysql,一个work进程,4个链接mysql连接池 本机查询mysql

zhttp's People

Contributors

keaixiaou avatar

Watchers

James Cloos avatar buffi avatar

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.