itsdamien / laravel-api-controller
此包已被弃用且不再维护。未建议替代包。
简化版的API控制器,受Jeffrey Way启发。兼容Laravel 5+和Lumen 5+。
v1.0.6
2020-09-14 18:29 UTC
Requires
- php: >=5.6.4
Requires (Dev)
- phpunit/phpunit: ~5.7
- satooshi/php-coveralls: ^1.0
README
这是一个简单的API控制器辅助特质,兼容Lumen 5+和Laravel 5+。该项目目标是使创建API项目变得简单。受Jeffrey Way(https://www.laracasts.com)启发
安装
composer require itsdamien/laravel-api-controller
基本设置/使用方法
use ItsDamien\Api\ApiController; class MyController extends Controller { use ApiController; public function index() { return $this->respond(['status' => 'hello world']); } }
API辅助函数
请浏览源代码以查看完整列表。
//200 response $this->respond(); //201 response $this->respondCreated(); //500 error $this->respondServerError(); //422 error $this->respondUnprocessable(); //General error $this->respondWithError('message here');
许可
Laravel Api Controller是开源软件,采用MIT许可证授权