Skip to content
No description, website, or topics provided.
PHP Shell
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests Change phpunit.xml db的环境变量 Aug 1, 2019
.gitignore update config provider Jul 26, 2019
.php_cs update composer.json Jul 26, 2019
.phpstorm.meta.php update composer.json Jul 26, 2019
.travis.yml feat 屏蔽DB部分的单测 Jul 31, 2019
README.md Change 删除readme中未完成章节 Aug 1, 2019
composer.json Change repalce namespace Jul 31, 2019
phpunit.xml Change phpunit.xml db的环境变量 Aug 1, 2019

README.md

Hyperf Validation

About

chunhei2008/hyperf-validation 是对Laravel Validation的移植(不包含门面部分),具体使用方法可以参考Laravel Validation 的使用。

Install

composer require chunhei2008/hyperf-validation

Config

publish config

php bin/hyperf.php  vendor:publish chunhei2008/hyperf-translation

config path

your/config/path/autoload/translation.php

config content

<?php

declare(strict_types=1);

/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
 */

return [
    'locale'          => 'en',   
    'fallback_locale' => '',
    'lang'            => BASE_PATH . '/resources/lang', 
];

exception handler

<?php

declare(strict_types=1);

/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
 */

return [
    'handler' => [
        'http' => [
            \Chunhei2008\Hyperf\Validation\ValidationExceptionHandler::class,
        ],
    ],
];

validation middleware

<?php

declare(strict_types=1);

/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
 */

return [
    'http' => [
        \Chunhei2008\Hyperf\Validation\Middleware\ValidationMiddleware::class,
    ],
];

Usage

gen request

php bin/hyperf.php gen:request FooRequest
class IndexController extends Controller
{
   

    public function foo(FooRequest $request)
    {
        // todo
    }
}


You can’t perform that action at this time.