luwake / php-express
A pipeline framework use express.js api for php
dev-master
2021-08-11 01:51 UTC
Requires
- gpolguere/path-to-regexp-php: dev-master
- petrgrishin/pipe: dev-master
- react/http: ^1.3
Suggests
- symfony/var-dumper: Subtree split of the Symfony VarDumper Component
This package is not auto-updated.
Last update: 2025-03-05 18:26:52 UTC
README
A pipeline framework use express.js api and reactphp framework for php
example
$app = Express::Application(); $app->get('/', function(Request $req, Response $res){ return $res->send('Hello World'); }); $app->listen(8080);
example 2 sub router
$app = Express::Application(); $post = Express::Router(); $post->get('/:id', function(Request $req, Response $res){ return $res->send('Hello Post:' . $req->params['id']); }); $post->get('/', function(Request $req, Response $res){ return $res->send('Hello Post'); }); $app->use('/post', $post); $app->get('/', function(Request $req, Response $res){ return $res->send('Hello World'); }); $app->listen(8080);
example 3 middleware use
$app = Express::Application(); $app->use(Express::static(__DIR__)); $api = Express::Router('/api'); $api->use(Express::json()); $api->get('/', function(Request $req, Response $res){ return [ 'code' => 0, 'msg' => '', 'data' => [], ]; }); $app->use($api); $app->get('/', function(Request $req, Response $res){ return $res->send('Hello World'); }); $app->listen(8080);
todo
some method need complete