karser / KarserRecaptcha3Bundle

Google ReCAPTCHA v3 for Symfony
MIT License
158 stars 21 forks source link

class "Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3Validator" does not exist #39

Closed nicolasmahler-fr closed 3 years ago

nicolasmahler-fr commented 3 years ago

Hi,

Thanks for your work. I've been able to make it work one time but since it throw an error while trying to reach the form page :

Cannot autowire argument $recaptcha of "App\Controller\ContactController::index()": it references class "Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3Validator" but no such service exists. You should maybe alias this class to the existing "karser_recaptcha3.validator" service.

Controller looks like that :

use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3Validator;

class ContactController extends AbstractController { /**

Symfony 5.2.3 Php : 7.4.15

Any thoughts?

Thanks :)

karser commented 3 years ago

That makes sense. I'll take a look tomorrow. You can send a pull request if you want

karser commented 3 years ago

@nicolasmahler-fr Can you please try this PR using the following command and see if it works?

 composer require "karser/karser-recaptcha3-bundle:dev-validator-alias"
nicolasmahler-fr commented 3 years ago

Thanks for your fast reply!

It didn't work. So I tried it in a fresh install, and everything works as expected. Then i remove this version, to test the regular one.

composer remove "karser/karser-recaptcha3-bundle:dev-validator-alias"

Did install the regular package :

composer require karser/karser-recaptcha3-bundle

And finally same problem occurs : Cannot autowire argument $recaptcha of "App\Controller\ContactController::index()": it references class "Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3Validator" but no such service exists. You should maybe alias this class to the existing "karser_recaptcha3.validator" service.

It seems like there's a problem when you remove then reinstall the package (?)

[EDIT] I did remove the regular package once again, to reinstall "karser/karser-recaptcha3-bundle:dev-validator-alias" one. There's no more the class error, but the captcha is not populated in the form.

karser commented 3 years ago

There's no more the class error

I merged the PR, so you can reinstall the package the regular way: composer require karser/karser-recaptcha3-bundle.

but the captcha is not populated in the form.

It only adds an alias, so please try again. If it worked before it will work now.

nicolasmahler-fr commented 3 years ago

I can confirm that it works like a charm right now!

Thanks

karser commented 3 years ago

Awesome!