How to Use reCAPTCHA in Laravel 5.2 Forms for Validation

In the year 1950, the father of modern computer sciences, Alan Turing developed a behavioral test that was to distinguish the machine-based behavior from the humans. The test became known as Turing’s Test, and the successful machines to complete this Turing test were considered equally good as humans in those particular tasks.

Turing planted the seed which has now grown into a completely new branch of computer science known as Artificial Intelligence. Since then, the bots have gotten smarter and sharper, which led us to the difficulty of sorting out the organic and bot traffic. These could be used for any false advertising impression or spamming at some web service. To overcome these problems, developers around the world came up with ideas to keep the bots at bay.

One of the ways to filter bot traffic is by using reCAPTCHA. It is a reverse Turing Test method to draw a line between organic and bots. reCAPTCHA, a rework of once-popular CAPTCHA, is a free online tool acquired and provided by Google.

It is a combination of knowledge and recognition-based interpretive response based on answer selection. The methodology lies in the machine learning from the Google’s large data sets of human interaction with the web, which is slightly different and random compared to a bot.

So, let’s learn how you can use the Google reCAPTCHA validation to validate your form in Laravel.


This one requires only two things:

  • You must have some knowledge about Laravel 5.2.
  • You must have a launched Laravel app on Cloudways PHP Platform. This one’s optional.

Step 1: Getting Necessary Packages

Let’s get the necessary classes we will require to make things possible. I’ll be using Composer to bring down the packages:

$ composer requirelaravelcollective/html $ composer requireanhskohbo/no-captcha

Step 2: Setting up Configurations

We are going to edit the app.php file.

$ vim config/app.php

Insert these lines in “providers” array:

Collective\Html\HtmlServiceProvider::class, Anhskohbo\NoCaptcha\NoCaptchaServiceProvider::class

Insert these lines in “aliases” array:

'Form'=>Collective\Html\FormFacade::class, 'Html'=>Collective\Html\HtmlFacade::class,

Step 3: Setting up Secret Keys

Originally published at

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.