Laravel using google captcha validation

install captcha dependence with composer

composer require buzz/laravel-google-captcha

add the class interface into ‘providers’ section in config/app.php


define alias into the ‘alias’ section

'GoogleCaptcha' => Buzz\LaravelGoogleCaptcha\CaptchaServiceProvider::class,

execute command to create configuration file

php artisan vendor:publish

edit the config file accordingly in config/captcha.php

  * Secret key and Site key get on
  * */
 return [
     'secret' => env('CAPTCHA_SECRET', 'default_secret'),
     'sitekey' => env('CAPTCHA_SITEKEY', 'default_sitekey'),
      * @var string|null Default ``null``.
      * Custom with function name (example customRequestCaptcha) or class@method (example \App\CustomRequestCaptcha@custom).
      * Function must be return instance, read more in repo ````
     'request_method' => null,
     'options' => [
         'multiple' => false,
         'lang' => app()->getLocale(),
     'attributes' => [
         'theme' => 'light'

the code to show the captcha in the form

{!! Captcha::display($attributes) !!}
This entry was posted in Development and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *