Laravel 8/7/6 Google ReCaptcha v2 Form Validation
Laravel Google ReCaptcha â In this section, you will learn how to incorporate Google v2 Re Captcha form validation (security) into your Laravel application forms. Today, we will incorporate Google Re Captcha into the Laravel application. We will create one form with Google Re Captcha and validate the form data with Laravel validations before storing it in the database. In this Google Re captcha tutorial, we will go over all of the steps and then provide a live demo button. Click the live demo button to put this Laravel Google Recaptcha integration to the test.
Laravel Google V2 Re Captcha Form Validation
To learn more about Captcha validation in Laravel, go to Google. You can validate form data with Google v2 reCaptcha validation by following the steps below.
Table of Content
- Download laravel Fresh Setup - Setup Database Credentials - Install Google Captcha Package - Get Google Captcha Secrets - Create Route - Generate Controller by Command - Create Blade View (form) - Run Development Server
Step 1: Download laravel Fresh Setup
We must first download new Laravel setups. To download the laravel fresh setup on your system, run the command below. composer create-project --prefer-dist laravel/laravel blog
Step 2: Setup Database Credentials
Following the successful download of the laravel application, Set up database credentials in your project's.env file before proceeding to the next step: DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=here your database name here DB_USERNAME=here database username here DB_PASSWORD=here database password here
Step 3: Install Google Captcha Package
In your Laravel 6 application, we'll now install the Google Captcha Package. Install this package in your Laravel application with the command below. composer require anhskohbo/no-captcha Open the config/app.php file and add service provider and alias after successfully installing Google Captcha Packages. config/app.php 'providers' => , 'aliases' =>
Step 4: Get Google Captcha Secrets
Now I'll make a site key and a secret key for Google Recaptcha in order to use it in a Laravel application. You only need to put the.env file if you already have site key and secret key. If you're not sure where we'll acquire secret key and secret site, use the link below and make your own secret credentials. Recaptcha is a new online registration system that uses a captcha system. The form will appear like this when you click this link Recaptcha new site registration. Fill in all of the required information and submit the form. After you submit the above form, you will be able to see your secret site and secret key. Here is where you should paste your credentials and your.env file. After that, we'll set the Google captcha secret in.env files. To do so, open a.env file and enter the following credentials:
Step 5: Create Route
We'll now add two routes to the web.php file, as seen below. The first is to display the form, and the second is to save the data from the form into the database. Open routes/web.php file Route::get('captcha-form', 'CaptchaController@captchForm'); Route::post('store-captcha-form', 'CaptchaController@storeCaptchaForm');
Step 6: Generate Controller by Command
We'll need to make a new controller called CaptchaController to handle two methods. Let's make a Controller with the command below. php artisan make:controller CaptchaController Now navigate to => app/Http/Controllers/CaptchaController.php to access the controller. Create some methods for displaying data and storing it in a database now. Read the full article











