2017 © Pedro Peláez
 

library http

An efficient swoole framework

image

easyswoole/http

An efficient swoole framework

  • Sunday, July 29, 2018
  • by kiss291323003
  • Repository
  • 0 Watchers
  • 2 Stars
  • 34 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 278 % Grown

The README.md

EasySwoole HTTP 服务组件

一个轻量级的HTTP Dispatch组件, (*1)

Server Script

namespace App\HttpController;
use EasySwoole\Http\AbstractInterface\Controller;

require_once 'vendor/autoload.php';


class Index extends Controller
{

    function index()
    {
        // TODO: Implement index() method
        $this->response()->write('hello world');
        $this->response()->setCookie('a','a',time()+3600);
    }

    function testSession()
    {
        $this->session()->start();
        $this->session()->set('a',time());
    }

    function testSession2()
    {
        $this->session()->start();
        $this->response()->write($this->session()->get('a'));
    }

    function testException()
    {
        new NoneClass();
    }

    protected function onException(\Throwable $throwable): void
    {
        $this->response()->write($throwable->getMessage());
    }

    protected function gc()
    {
        parent::gc();
        var_dump('class :'.static::class.' is recycle to pool');
    }
}


$http = new \Swoole\Http\Request("0.0.0.0", 9501);
$http->set([
    'worker_num'=>1
]);

$http->on("start", function ($server) {
    echo "Swoole http server is started at http://127.0.0.1:9501\n";
});

$service = new \EasySwoole\Http\WebService();
$service->setExceptionHandler(function (\Throwable $throwable,\EasySwoole\Http\Request $request,\EasySwoole\Http\Response $response){
    $response->write('error:'.$throwable->getMessage());
});

$http->on("request", function ($request, $response)use($service) {
    $req = new \EasySwoole\Http\Request($request);
    $service->onRequest($req,new \EasySwoole\Http\Response($response));
});

$http->start();

动态路由匹配规则

Dispatcher, (*2)

The Versions

29/07 2018

dev-master

9999999-dev https://www.easyswoole.com/

An efficient swoole framework

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by YF

framework async swoole easyswoole

26/07 2018

1.0.6

1.0.6.0 https://www.easyswoole.com/

An efficient swoole framework

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by YF

framework async swoole easyswoole

23/07 2018

1.0.5

1.0.5.0 https://www.easyswoole.com/

An efficient swoole framework

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by YF

framework async swoole easyswoole

23/07 2018

1.0.4

1.0.4.0 https://www.easyswoole.com/

An efficient swoole framework

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by YF

framework async swoole easyswoole

01/07 2018

1.0.3

1.0.3.0 https://www.easyswoole.com/

An efficient swoole framework

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by YF

framework async swoole easyswoole

01/07 2018

1.0.2

1.0.2.0 https://www.easyswoole.com/

An efficient swoole framework

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by YF

framework async swoole easyswoole

28/05 2018

1.0.1

1.0.1.0 https://www.easyswoole.com/

An efficient swoole framework

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by YF

framework async swoole easyswoole

25/05 2018

1.0.0

1.0.0.0 https://www.easyswoole.com/

An efficient swoole framework

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by YF

framework async swoole easyswoole