Google ReCaptcha integration with Laravel Project

Generic placeholder image
Brijpal Sharma
php laravel  

Date:-June 19th, 2018 , Posted On:- Web Development

Today we learn how to add Google ReCaptcha in our Laravel Project in easy steps. Basically ReCaptcha protects your website from spam and abuse.

Step 1

First, we need a google account where you will create site key and secret key.


Registering the site

You can also test Google ReCaptcha on your localhost. This will only work if you access localhost using rather than localhost.

After successfully registration your site, you will be redirected to captcha keys (Site key and Secret Key).

 next step is to edit in the View file.



Step 2

Add this code where you want to show Google ReCaptcha in your Laravel Project.

<div class="g-recaptcha" data-sitekey="Your_site_key"></div>


Step 3

Now we add some code in Controller to verify Google ReCaptcha and other data filled by users.

Here we suppose we are working on the contact form.

public function postContact(Request $request)
        'subject' => 'required',


      $token = $request->input('g-recaptcha-response');
      if ($token > 0) 
        //Code to store data
      } else {
        //Error ,Please Fill Google Recaptcha

Run your project and see the result. 


About the author

user profile
Brijpal Sharma

Hello, My Name is Brijpal Sharma. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of Codermen. I started this blog to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers...


You must be logged in to post a comment.