chunhei2008/hyperf-validation 是对Laravel Validation的移植(不包含门面部分),具体使用方法可以参考Laravel Validation 的使用。已不再维护,推荐使用Hyperf官方组件
composer require chunhei2008/hyperf-validation
php bin/hyperf.php vendor:publish chunhei2008/hyperf-translation
your/config/path/autoload/translation.php
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact [email protected]
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
return [
'locale' => 'en',
'fallback_locale' => '',
'lang' => BASE_PATH . '/resources/lang',
];
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact [email protected]
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
return [
'handler' => [
'http' => [
\Chunhei2008\Hyperf\Validation\ValidationExceptionHandler::class,
],
],
];
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact [email protected]
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
return [
'http' => [
\Chunhei2008\Hyperf\Validation\Middleware\ValidationMiddleware::class,
],
];
php bin/hyperf.php gen:request FooRequest
class IndexController extends Controller
{
public function foo(FooRequest $request)
{
// todo
}
}