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
Laravel API Response
主要功能
- 🎯 统一标准化返回格式
- 🔧 支持自定义状态码和扩展字段
- 📦 支持自定义响应头
- 🚀 完美兼容 Laravel API 资源
- 🛑 统一异常处理格式
环境需求
以下为最低环境要求:
- PHP >= 8.2
- Laravel ^11.0|^12.0
安装
输出格式
使用
可用方法
包含三个方法 success
, error
, deny
, 分别对应成功, 失败, 登录失效三种情况.
自定义状态码以及扩展字段
在 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/http Version ^11 || ^12
illuminate/pagination Version ^11 || ^12
illuminate/support Version ^11 || ^12
illuminate/http Version ^11 || ^12
illuminate/pagination Version ^11 || ^12
illuminate/support Version ^11 || ^12
The package mitoop/laravel-api-response contains the following files
Loading the files please wait ....