I’m trying to implement recaptcha for my project written in PHP and Yii2 and I’m using himiklab’s widget. I tried to follow the steps mentioned in the Readme File but I couldnt get it working.
I tried adding the widget rule in composer.json file and did a composer update on terminal and I see this as below.
[ReflectionException]
Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist
[ErrorException]
Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository::whatProvides(Compose
r\DependencyResolver\Pool $pool, $name) should be compatible with Composer\Repository\ComposerRep
ository::whatProvides(Composer\DependencyResolver\Pool $pool, $name, $bypassFilters = false)
I even tried to install it using composer using composer require --prefer-dist "himiklab/yii2-recaptcha-widget" "*" and I get the same error as above image.
My code: Signup form.php
public function rules() {
return [ ...
[['reCaptcha'],\himiklab\yii2\recaptcha\ReCaptchaValidator::SignupForm(), 'secret' => 'secretkey', 'uncheckedMessage' => 'Please confirm that you are not a bot.']
];
}
signup.php (view)
<?= $form->field($model, 'reCaptcha')->widget(\himiklab\yii2\recaptcha\ReCaptcha::SignupForm(),['siteKey' => 'sitekey']) ?>
main.php
return [
'components' => [ 'reCaptcha' => [ 'name' => 'reCaptcha', 'class' => 'himiklab\yii2\recaptcha\ReCaptcha', 'siteKey' => 'siteKey', 'secret' => 'secretKey', ],
...
]
When I ignored the installation of widget using composer and continued with adding the widget in composer.json file "himiklab/yii2-recaptcha-widget" : "*" and running the application, I see the error mentioned in the heading.
Did anyone face the same issue? Can someone help me in solving this. TIA