Download the PHP package goletter/hyperf-resource without Composer
On this page you can find all versions of the php package goletter/hyperf-resource. 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 hyperf-resource
Hyperf API Resource
基于 hyperf/resource 的 API 资源层:统一响应信封、?include= 关联预加载、ApiResponse 辅助方法。
安装
发布配置(可选,用于自定义 Resource 命名空间):
响应信封
成功响应会附带:
code / message 可通过 success() / collection() 第三个、第四个参数传入。
快速使用
在 Service / Controller 中使用 ApiResponse(goletter/hyperf-server 的 Service 已默认引入):
自动解析命名空间默认 App\Resource,可在 .env 或 config/autoload/resource.php 修改:
编写 Resource
请求示例:
未出现在白名单中的 include 会被忽略,避免随意加载关联。
分页
传入分页器时,会输出精简后的 meta(含 total 等)。若项目使用 goletter/hyperf-server 的 ResponseFormatMiddleware,会将 meta.total 提升为顶层 total。
说明
- 集合会先统一
loadMissing,再实例化子 Resource,避免 N 次重复预加载。 fail()/BusinessException支持int或BackedEnum(若 Enum 有label()/getMessage()会用作默认文案)。- 请在应用内注册
BusinessException的异常处理器,以返回与成功响应一致的 JSON 信封。
All versions of hyperf-resource with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
goletter/hyperf-utils Version ^1.0
hyperf/collection Version ^3.1
hyperf/context Version ^3.1
hyperf/contract Version ^3.1
hyperf/db-connection Version ^3.1
hyperf/resource Version ^3.1
hyperf/server Version ^3.1
hyperf/stringable Version ^3.1
goletter/hyperf-utils Version ^1.0
hyperf/collection Version ^3.1
hyperf/context Version ^3.1
hyperf/contract Version ^3.1
hyperf/db-connection Version ^3.1
hyperf/resource Version ^3.1
hyperf/server Version ^3.1
hyperf/stringable Version ^3.1
The package goletter/hyperf-resource contains the following files
Loading the files please wait ...