mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-30 02:37:58 +08:00
Merge pull request #640 from yangliulnn/patch-1
Format src/validation/README.md
This commit is contained in:
commit
b6c6c13aac
@ -1,73 +1,44 @@
|
||||
# Hyperf Validation
|
||||
|
||||
|
||||
## About
|
||||
|
||||
[hyperf/validation](https://github.com/hyperf-cloud/validation) 组件衍生于 `Laravel Validation` 组件的,我们对它进行了一些改造,大部分功能保持了相同。在这里感谢一下 Laravel 开发组,实现了如此强大好用的 Validation 组件。
|
||||
|
||||
## Install
|
||||
## Installation
|
||||
|
||||
```
|
||||
composer require hyperf/validation
|
||||
|
||||
```
|
||||
|
||||
## Config
|
||||
|
||||
### Publish config file
|
||||
|
||||
### publish config
|
||||
```
|
||||
php bin/hyperf.php vendor:publish hyperf/validation
|
||||
|
||||
```
|
||||
|
||||
### config path
|
||||
### Configuration path
|
||||
|
||||
```
|
||||
your/config/path/autoload/translation.php
|
||||
|
||||
```
|
||||
|
||||
### config content
|
||||
### Configuration
|
||||
|
||||
```
|
||||
```php
|
||||
<?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
|
||||
### Exception handler
|
||||
|
||||
```
|
||||
```php
|
||||
<?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' => [
|
||||
@ -75,49 +46,34 @@ return [
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
```
|
||||
|
||||
### validation middleware
|
||||
### Validation middleware
|
||||
|
||||
```
|
||||
```php
|
||||
<?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' => [
|
||||
\Hyperf\Validation\Middleware\ValidationMiddleware::class,
|
||||
],
|
||||
];
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
### gen request
|
||||
### Generate form request
|
||||
|
||||
Command:
|
||||
```
|
||||
php bin/hyperf.php gen:request FooRequest
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
class IndexController extends Controller
|
||||
Usage:
|
||||
```php
|
||||
class IndexController
|
||||
{
|
||||
|
||||
|
||||
public function foo(FooRequest $request)
|
||||
{
|
||||
$request->input('foo');
|
||||
@ -149,6 +105,4 @@ class IndexController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
```
|
Loading…
Reference in New Issue
Block a user