2017 © Pedro Peláez
 

library yaf_swoole_plug

swoole_web_server结合yaf实现高效api接口

image

gnp/yaf_swoole_plug

swoole_web_server结合yaf实现高效api接口

  • Monday, July 31, 2017
  • by gnpok
  • Repository
  • 1 Watchers
  • 2 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yaf结合swoole httpserver写的api接口

为什么写这个

参照了 LinkedDestiny xuebingwang ,觉得太裸露,就决定用composer形式来写,同时也是一种锻炼, (*1)

程序我会在应用中进一步完善,同时希望大家给点意见, (*2)

Requirement

  • yaf扩展
  • swoole扩展

如何使用

1.生成yaf框架

生成yaf框架, (*3)

2.使用composer安装

在yaf框架根目录下面使用命令行输入, (*4)

$ composer require gnp/yaf_swoole_plug dev-master 

然后更新composer, (*5)

$ composer update
//修改yaf框架入口文件

define('APPLICATION_PATH', dirname(__FILE__));
require_once dirname(__FILE__).'/vendor/autoload.php';

if (PHP_SAPI === 'cli'){
    //传入swoole的配置
    $config = array();
    Ysp\Entry::startServer($config);
}else{
    //这边是传统的apache或php-fpm模式
    $application = new Yaf_Application( APPLICATION_PATH . "/conf/application.ini");
    $application->bootstrap()->run();
}

//为了方便,我封装了get和post方法,存放在src/common/function.php
将代码拷贝出来,放入框架中去

启动服务, (*6)

//进入yaf框架入口文件对应目录,在命令行模式下输入
php index.php

//打开浏览器,输入localhost:9501
hello world

3.与nginx结合

参考我另一个项目中的说明, (*7)

4.swoole的异步任务

参考我另一个项目中的说明, (*8)

The Versions

31/07 2017

dev-master

9999999-dev

swoole_web_server结合yaf实现高效api接口

  Sources   Download

Apache-2.0

The Requires

 

by gnp