Giter Site home page Giter Site logo

yafapi's Introduction

yaf+swoole_http_server

##项目描述

使用swoole_http_server + yaf 专注于网站api接口,同时能处理异步任务,如异步发送邮件,发送短信验证码等耗时相对长一点的任务

本项目兼容php-fpm模式,不过在异步任务调用处要调整

参照 LinkedDestiny
参照 xuebingwang

##使用说明

//1.安装yaf,swoole扩展
composer install
composer dump-autoload -o 


//2.配置Nginx反向代理,将所有请求代理到swoole端口上,配置如下
location / {
	proxy_set_header Connection "keep-alive";
	proxy_set_header Host $http_host;
	proxy_http_version 1.1;
	proxy_pass http://127.0.0.1:9501;
}

//打开终端
cd yafApi/public
php http_server.php

##注意事项

  1. 若你的接口需要多版本控制,需要配置modules,或参考xuebingwang
  2. 调用task时候注意事项
//1.当使用如下代码时候,可以在controller中调用task
$this->application->bootstrap();
//controller中代码
HttpServer::$http->task(time());  


//2.当入口文件使用如下代码时候
$this->application->bootstrap()->run();
//在controller中调用则会报出如下错误
PHP Fatal error:  Call to a member function task()

** 不懂C,现阶段专注于应用层,未涉及底层代码,望请大神指教**

yafapi's People

Contributors

gnpok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.