peterfox / laravel-recaptcha

A simple Recaptcha set up for Laravel 5
MIT License
0 stars 1 forks source link

class RecaptchaFacade not found #1

Open rashcms opened 7 years ago

rashcms commented 7 years ago

Hi How to use laravel recaptcha in laravel version 5.3 ? ErrorException in AliasLoader.php line 66: Class '\Recaptcha\Facade\RecaptchaFacade' not found

sgilberg commented 7 years ago

I have the same issue. Looks like some of the class names used in the RecaptchaServiceProvider class are incorrect, both with the AliasLoader and in the use statements.

ghost commented 7 years ago

I managed to resolve this issue by changing few lines in the RecaptchaServiceProvider. It seems the error was in the order of the arguments in the call to the AliasLoader.

  1. Change AliasLoader::getInstance()->alias('\Recaptcha\Facade\RecaptchaFacade', 'Recaptcha'); to AliasLoader::getInstance()->alias('Recaptcha', '\Recaptcha\Facade\RecaptchaFacade');

  2. Change use App\RecaptchaLaravel\Core\RecaptchaClient; use App\RecaptchaLaravel\Facade\RecaptchaFacade; use App\RecaptchaLaravel\Validator\RecaptchaValidator; to use RecaptchaLaravel\Core\RecaptchaClient; use RecaptchaLaravel\Facade\RecaptchaFacade; use RecaptchaLaravel\Validator\RecaptchaValidator;

EDIT:

If you use the Facade in your Blade template, don't forget to add <script src="https://www.google.com/recaptcha/api.js"></script> to your template. This instruction is omitted in the README.md