In this tutorial we will take alook on how to to apply invisible google reCAPTCHA on a laravel application hope you enjoy it.
Step 1: We will create a brand new laravel application by typing the following command on your terminal
~$ composer create-project laravel/laravel recaptcha
~# cd recaptcha/
Step 2: We will strat installing invisible google package from github.com by typing the following command on the terminal:
go to github.com and search for albertcht/invisible-recaptcha to find more.
~$ composer require albertcht/invisible-recaptcha
Step 3: Setup the recaptcha on laravel 5
Add ServiceProvider to the providers array in config/app.php
AlbertCht\InvisibleReCaptcha\InvisibleReCaptchaServiceProvider::class,
Step 4: Configuring reCAPTCHA
You have to create your keys by visiting https;//www.google.com/recaptcha ,and go to <admin console>
Step 5: Adding keys
In your .env file add the following
INVISIBLE_RECAPTCHA_SITEKEY=<siteKey>
INVISIBLE_RECAPTCHA_SECRETKEY=<secretKey>
INVISIBLE_RECAPTCHA_BADGEHIDE=false
INVISIBLE_RECAPTCHA_DATABADGE='bottomright'
INVISIBLE_RECAPTCHA_TIMEOUT=5
INVISIBLE_RECAPTCHA_DEBUG=false
Step 6: How to use
Create the form your wishing to add reCAPTCHA between the <form></form> add this in the blade to render your recaptcha
@captcha()
inside the controller you must validate the recaptcha by adding the following
$this->validate($request, [
'g-recaptcha-response' => 'required|captcha'
]);
That's it :D
Follow me @zaidjaber
Category: How To
Comments (0)