1 Star 2 Fork 0

zhen/hyperf-kit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

安装

composer require zhen/hyperf-kit

如果需要使用 表单验证器,需要做以下操作

参考:https://hyperf.wiki/2.2/#/zh-cn/validation

添加中间件

您需要为使用到验证器组件的 Server 在 config/autoload/middlewares.php 配置文件加上一个全局中间件 Hyperf\Validation\Middleware\ValidationMiddleware 的配置,如下为 http Server 加上对应的全局中间件的示例:

<?php
return [
    // 下面的 http 字符串对应 config/autoload/server.php 内每个 server 的 name 属性对应的值,意味着对应的中间件配置仅应用在该 Server 中
    'http' => [
        // 数组内配置您的全局中间件,顺序根据该数组的顺序
        \Hyperf\Validation\Middleware\ValidationMiddleware::class
        // 这里隐藏了其它中间件
    ],
];

添加异常处理器

config/autoload/exceptions.php

return [
    'handler' => [
        'http' => [
            \Zhen\HyperfKit\Exception\Handler\ValidationExceptionHandler::class,
        ],
    ],
];

发布验证器语言文件

php bin/hyperf.php vendor:publish hyperf/translation
php bin/hyperf.php vendor:publish hyperf/validation

异常处理说明

.env 中的 APP_ENV=devAPP_DEBUG=true 表示当前为开发环境,会将异常详细信息返回,不会走其他逻辑处理

The MIT License (MIT) Copyright (c) Zhen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

hyperf 框架核心类封装 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/easy_code/hyperf-kit.git
git@gitee.com:easy_code/hyperf-kit.git
easy_code
hyperf-kit
hyperf-kit
master

搜索帮助