Laravel 8 google recaptcha form validation example tutorial

Laravel 8 google recaptcha form validation example tutorial

In this tutorial, we are going to integrate the Google reCAPTCHA in Laravel 8. normally captcha is used for security purposes and only human users can pass through. computers or bots are not solving a captcha. so we will learn about captcha that how to integrate the Google reCAPTCHA in laravel 8.

In this example, we will integrate the Google reCAPTCHA in laravel 8 using the “anhskohbo/no-captcha” pacakge. so you can follow the below step.

Overview
Step 1: Install Laravel
Step 2: Install Package
Step 3: Add providers and aliases
Step 4: Get and Set Google Captcha Secrets
Step 5: Create Route
Step 6: Create a Controller
Step 7: Create Blade Files
Step 8: Run The Application

Step 1: Install Laravel
We are going to install laravel 8, so first open the command prompt or terminal and go to xampp htdocs folder directory using the command prompt. after then run the below command.

Step 2: Install Package
Now, we are going to install the “anhskohbo/no-captcha” package using the below command.

Step 3: Add providers and aliases
We will add below providers and aliases in the “config/app.php” file

Step 4: Get and Set Google Captcha Secrets
First, we need to Google reCAPTCHA site key and secret key. so first we go to Google reCAPTCHA panel and get the site key and secret key.
After getting the keys, we will set the key in the .env file. so you can see our code.

Step 5: Create Route
Add the following route code in the “routes/web.php” file.

Step 6: Create a Controller
Here below command help to create the controller and model.
StudentController.php

Step 7: Create Blade Files
So finally, first we will create the student.blade.php files in the “resources/views” directory.
student.blade.php

Step 8: Run The Application
We can start the server and run this application using the below command.

Now we will run our example using the below Url in the browser.