evalok / php-rest-lightly
轻量级组件,用于实现REST API
0.1.2
2016-03-16 13:10 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-09-14 15:37:30 UTC
README
轻量级组件,用于实现REST API
此库帮助您利用命名空间隐式定义API端点路由,而不是手动编写;添加新端点不需要您更新路由列表
认证或其他操作可以在端点类内部完成
安装说明
composer require evalok/php-rest-lightly
示例用法:https://github.com/EvaLok/php-rest-lightly/blob/master/demo/public/index.php
演示
在 demo/public 中配置 .htaccess
示例
GET: api/v1/Thing1/555
{ id: 555, owner: { *owner: null }, class: "api\v1\Thing1", method: "api\v1\Thing1::get", message: "testing testing 123", params: [ ] }
GET: api/v1/Thing1/555/Thing2/777?some=thing
{ id: 777, owner: { *id: 555, *owner: { } }, class: "api\v1\Thing1\Thing2", method: "api\v1\Thing1\Thing2::get", message: "testing testing 123", params: { some: "thing" } }
api/v1/Restricted/Thing3/888
"403: Forbidden"
待办事项
- 测试
- 版本降级演示
- 非JSON响应
- 支持请求头