hoangdo/laravel-json-api
最新稳定版本:v0.1.0
Composer 安装命令:
composer require hoangdo/laravel-json-api
包简介
The Json Response formatter library for laravel
README 文档
README
A library that will help you format the response easily
Installation
composer require hoangdo/laravel-json-api
Usage
Just normal use it as a middleware
// web.php Route::get('foo', 'FooController@index')->middleware('json'); // or Route::middleware('json')->group(function () { Route::get('foo', 'FooController@index'); Route::get('bar', 'BarController@index'); })
If you want to use it global for all api, just add it to the api group middleware
// app/Http/Kernel.php ... protected $middlewareGroups = [ ... 'api' => [ // Add it here 'json', 'throttle:60,1', \Illuminate\Routing\Middleware\SubstituteBindings::class, ], ... ]; ...
If you want to change the middleware alias name, for avoid conflict with another libraries, just fix it by .env
# You can add multiple aliases, separated by "," JSON_MIDDLEWARE_NAME=json1,json2
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-22