chunhei2008 / hyperf-validation
This package is abandoned and no longer maintained.
No replacement package was suggested.
chunhei2008/hyperf-validation
v1.0.2
2019-09-20 09:51 UTC
Requires
- php: >=7.2
- ext-swoole: >=4.3
- chunhei2008/hyperf-translation: ^1.0
- egulias/email-validator: ^2.1
- hyperf/command: ^1.0
- hyperf/database: ^1.0
- hyperf/devtool: ^1.0
- hyperf/di: 1.0.*
- hyperf/framework: 1.0.*
- hyperf/http-server: ~1.0.0
- hyperf/utils: 1.0.*
- nesbot/carbon: ^2.21
- psr/container: ^1.0
- psr/http-message: ^1.0
- symfony/http-foundation: ^4.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- hyperf/db-connection: ^1.0
- hyperf/testing: 1.0.*
- mockery/mockery: ^1.2
- phpstan/phpstan: ^0.10.5
- swoft/swoole-ide-helper: dev-master
This package is auto-updated.
Last update: 2020-08-20 11:39:34 UTC
README
About
chunhei2008/hyperf-validation 是对Laravel Validation的移植(不包含门面部分),具体使用方法可以参考Laravel Validation 的使用。已不再维护,推荐使用Hyperf官方组件
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
}
}