1. Go to this page and download the library: Download yulibo/hyperf-validate library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yulibo / hyperf-validate example snippets
use Ylb\Validate\Annotations\RequestValidation;
/**
* @RequestValidation(filter=true,throw=true)
*/
public function login(){
//这里取到的 $data 是安全的。
$data = $this->request->getParsedBody();
}
use Ylb\Validate\Annotations\Validation;
/**
* @Validation(mode="Admin",scene="login",field="data")
* @Validation(mode="Admin",scene="array的规则",field="array")
* @Validation(mode="Admin",scene="array2的规则",field="array2")
*/
public function login($data,$array,$array2){
//这里取到的 $data,$array,$array2 是安全的,经过验证器验证过的
}