photon / api-json
用于创建带有 JSON 和 CORS 的 REST API 的视图助手
v1.4.0
2020-10-20 13:35 UTC
Requires
- php: ^7.0
- photon/photon: ^2.0
Requires (Dev)
- phpunit/phpunit: ^5.0
- squizlabs/php_codesniffer: ^3.2
README
用于创建 REST API 的视图助手
快速开始
- 添加模块
使用 composer 在项目中添加模块
composer require "photon/api-json:dev-master"
或特定版本
composer require "photon/api-json:1.0.0"
- 创建 API 端点
每个类将处理一个 URL 的所有 HTTP 方法
class MyAPIEndpoint extends \photon\views\APIJson\Rest
{
public function GET($request, $match)
{
return array(
'ok' => true,
'method' => $request->method
);
}
}
- 享受!