所以我试图使用Yii2 reCaptcha小部件:http://www.yiiframework.com/extension/yii2-recaptcha-widget/
但是,为其设置验证规则
['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => Yii::$app->params['reCAPTCHA.secretKey']
我收到错误Class 'himiklab\yii2\recaptcha\ReCaptchaValidator' not found
。我对Composer和Yii2很陌生,所以我不确定我错过了什么。
composer.json
{
"autoload" : {
"psr-4" : {
"Gaiatools\\Yii\\" : "src"
}
},
"name" : "gaiatools/site",
"require" : {
"php" : ">=7.0",
"himiklab/yii2-recaptcha-widget" : "*"
}
}
供应商/作曲家/ autoload_psr4.php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'yii\\composer\\' => array($vendorDir . '/yiisoft/yii2-composer'),
'yii\\' => array($vendorDir . '/yiisoft/yii2'),
'himiklab\\yii2\\recaptcha\\' => array($vendorDir . '/himiklab/yii2-recaptcha-widget'),
'cebe\\markdown\\' => array($vendorDir . '/cebe/markdown'),
'Gaiatools\\Yii\\' => array($baseDir . '/src'),
);
答案 0 :(得分:1)
将此行添加到require
文件
project-directory/composer.json
部分
"himiklab/yii2-recaptcha-widget" : "*"
然后在项目目录命令中运行:
composer update
答案 1 :(得分:0)
在项目目录内的终端中运行以下命令。它将自动添加到composer.json文件中。
composer require --prefer-dist "himiklab/yii2-recaptcha-widget" "*"