Download the PHP package gb-hyperf/framework without Composer
On this page you can find all versions of the php package gb-hyperf/framework. 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 framework
Framework
发布配置文件
response 介绍
response 主要用来统一 API 开发过程中「成功」、「失败」以及「异常」情况下的响应数据格式。 实现过程简单,在原有的 $response->json()进行封装,使用时不需要有额外的心理负担。 遵循一定的规范,返回易于理解的 HTTP 状态码,并支持定义 ResponseCodeEnum 来满足不同场景下返回描述性的业务操作码。
概览
- 统一的数据响应格式,固定包含:
code
、type
、result
、message
、error
(响应格式设计源于:RESTful服务最佳实践 ) - 支持配置返回字段是否显示,以及为她们设置别名,比如,将
message
别名设置为msg
,或者 分页数据第二层的data
改成list
(res.data.data -> res.data.list) - 内置 Http 标准状态码支持,同时支持扩展 ResponseCodeEnum 来根据不同业务模块定义响应码(可选,需要安装
jiannei/laravel-enum
)
成功响应
示例代码
返回单条数据
其他快捷方法(非项目api中使用)
控制器api响应模式(项目api响应模式)
命令行介绍
添加Action
- 根据项目规范快速创建Action。
- 参数一class名称,无需定义根命名空间会根据path自动匹配命名空间前缀
- 参数二 --path 即生成Action的路径
生成文件结构
生成model
- 重写Hyperf框架gen:model 命令。
- 参数同gen:model参数。
请先阅读 [Hyperf 框架模型章节](模型 (hyperf.wiki))
执行命令后会同时在Model目录下创建Contract/${model}Contract
接口类,及SERVICE/${MODEL}Service
服务类。
服务契约绑定如果命名规范不是
${model}Contract
=>SERVICE/${MODEL}Service
需要自行在config/autoload/dependencies.php
内添加绑定契约接口服务的绑定关系。 请参阅 [Hyperf 框架DI章节](依赖注入 (hyperf.wiki)))
All versions of framework with dependencies
PHP Build Version
Package Version
The package gb-hyperf/framework contains the following files
Loading the files please wait ....