Download the PHP package mitoop/laravel-api-response without Composer
On this page you can find all versions of the php package mitoop/laravel-api-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package laravel-api-response
API Response Trait
🔮 统一 Laravel 接口的返回格式,让数据结构更规范、更易于前后端协作。
环境需求
- PHP >= 8.2
- Laravel ^11.0|^12.0
安装
输出格式
普通格式
page 分页格式
cursor 分页格式
使用
可用方法
包含三个方法 success
, error
, reject
, 分别对应成功, 失败, 登录失效三种情况.
自定义状态码以及扩展字段
在 AppServiceProvider@boot
方法中添加如下代码
API 资源
支持 API 资源, 只需要
改下继承关系, 其他不需要任何改变.
Tips: 更改下系统默认的 stub
, 每次直接生成好继承关系.
普通资源继承 Mitoop\Http\Resources\Resource
资源集合继承 Mitoop\Http\Resources\ResourceCollection
和原来一样直接返回
异常
通过 render
方法统一处理异常输出格式.
License
MIT
All versions of laravel-api-response with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.2
illuminate/pagination Version ^11|^12
illuminate/http Version ^11|^12
illuminate/support Version ^11|^12
illuminate/pagination Version ^11|^12
illuminate/http Version ^11|^12
illuminate/support Version ^11|^12
The package mitoop/laravel-api-response contains the following files
Loading the files please wait ....