brenodouglas / react-restify
使用 ReactPHP 创建 RESTful API
0.3.0
2016-01-08 10:52 UTC
Requires
- guzzlehttp/promises: ^1.0
- react/http: dev-master
This package is not auto-updated.
Last update: 2024-09-10 18:51:34 UTC
README
为 ReactPHP 简化 RESTful API 的实现,真的很简单。
## 安装 在你的 composer.json
"require" : {
"capmousse/react-restify": "dev-master"
},
## 创建服务器
以下是一个简单的 HTTP 服务器示例,它会对所有 GET 请求进行响应,如 http://127.0.0.1:1337/hello/you
require 'vendor/autoload.php'; $server = new CapMousse\ReactRestify\Server("MyAPP", "0.0.0.1"); $server->get('/hello/{name}', function ($request, $response, $next) { $response->write("Hello ".$request->name); $next(); }); $runner = new CapMousse\ReactRestify\Runner($server); $runner->listen(1337);
更多示例可以在示例目录中找到,例如最完整的 Todo 示例。
设计目标
React-Restify 主要用于轻松构建 RESTful API。它可以像 Silex 一样使用,但没有框架部分。
下一部分将是支持 Sockets、升级请求... 以创建实时 API 服务器。
## 许可证
MIT,请参阅 LICENCE 文件