PHP code example of ezijing / yii2-validator
1. Go to this page and download the library: Download ezijing/yii2-validator 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/ */
ezijing / yii2-validator example snippets
return [
'id' => 'crontab-console',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'app\commands',
'timeZone' => 'Asia/Shanghai',
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
// 配置依赖关系
'container' => [
'definitions' => [
'King\Yii2Validator\ValidatorModelInterface' => 'King\Yii2Validator\model\ValidatorModel',
'King\Yii2Validator\Validator' => 'King\Yii2Validator\model\ParamsValidator',
],
'singletons' => [
],
],
// 配置组件
'components' => [
'validator' => 'King\Yii2Validator\Validator',
]
];
use components\validator\Validator;
/**
* 微信.
*/
class TestController extends \yii\rest\Controller
{
public function actionAsyncOfficialAccountUsers(Validator $validator)
{
$data = $this->request->get();
$rules = [
[['appid', 'experiment_id', 'connection_id'], '
/* @var \King\Yii2Validator\model\ParamsValidator $validator */
$validator = \Yii::$app->validator;
$data = [
'appid' => 'tesdasda',
];
$rules = [
[['appid', 'experiment_id', 'connection_id'], '