TechBooky AI Assistant
TechBooky AI Assistant
👋 Welcome to TechBooky AI Assistant

I can help with:
🔎 Tech News
🤖 AI Topics
💻 Gadgets
☁️ Cloud
✍️ Guest Posts
📢 Advertising
🔗 Backlinks
📩 Newsletter
  • AI Search
  • Cryptocurrency
  • Earnings
  • Enterprise
  • About TechBooky
  • Submit Article
  • Advertise Here
  • Contact Us
TechBooky
  • African
  • AI
  • Metaverse
  • Gadgets
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
  • African
  • AI
  • Metaverse
  • Gadgets
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
TechBooky
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Home Tips

How To Generate Google Recaptcha Code In Laravel?

Contributor by Contributor
July 9, 2019
in Tips
Share on FacebookShare on Twitter

Recaptcha is an automatic captcha recognition service designed for the needs of webmasters and website owners. They use it on websites in order to distinguish real people from spambots. For website designers, developers, admins, such a โ€œpass systemโ€ is simply irreplaceable as it helps them to stop the unwanted traffic to the site. These days, the Laravel application is being used by many companies. If you are a Laravel Developer and want to generate Google Recaptcha code in Laravel, letโ€™s follow the recommendations below:

  • Configure Laravel Application

You can install a new Laravel Application by using the following command.

composer create-project –prefer-dist laravel/laravel laravelrecaptcha

  • Install anhskohbo/no-captcha Packageย 

At first, you need to install anhskohbo/no-captcha Package for Google Recaptcha code. It will help you to generate a reCaptcha code for your application. Navigate to the command line and use the following command line.

composer require anhskohbo/no-captcha

  • Publish Configure File

It supports the auto-discovery feature of Laravel 5.5+. So, to do so, use the following command to Publish Config File-

php artisan vendor:publish –provider=”Anhskohbo\NoCaptcha\NoCaptchaServiceProvider”

  1. Set Google Site Key and Secret Key

Now, you should set Google Site Key and Secret Key in the .env file. If you have no Site Key and Secret Key, generate it from using this link.

Now, you need to open a .env file and add two keys:

NOCAPTCHA_SECRET=xxxx

NOCAPTCHA_SITEKEY=xxxx

  1. Develop One Controller

Use the following code to create one controller-

php artisan make:controller RecaptchaController –resource.

You also need to define validation in the controller file.

//RecaptchaController.php

public function create()

ย ย ย  {

ย ย ย ย ย ย ย  return view(‘recaptchacreate’);

ย ย ย  }

ย ย public function store(Request $request)

ย ย ย  {

ย ย ย ย ย ย ย  $request->validate([

ย ย ย ย ย ย ย ย ย ย ย  ‘name’ => ‘required’,

ย ย ย ย ย ย ย ย ย ย ย  ’email’ => ‘required|email’,

ย ย ย ย ย ย ย ย ย ย ย  ‘password’ => ‘required|min:6’,

ย ย ย ย ย ย ย ย ย ย ย  ‘g-recaptcha-response’ => ‘required|captcha’

ย ย ย ย ย ย ย  ]);

ย ย ย ย ย ย ย  return “success”;

ย ย ย  }

In tore() function, put the validation. In case this process fails, it will show an error.

  1. Define Routes

You must explore the route in routesย  >>ย  web.php file.

//web.php

Route::get(‘recaptchacreate’, ‘RecaptchaController@create’);

Route::post(‘store’, ‘RecaptchaController@store’);

You should defineย  Two(2) routes in the web.php file. The first route is to display the login page. And, the second route is used to make a post request.

  1. Create One View File

You need to create a file in the resourcesย  >>ย  viewsย  >>ย ย  recaptchacreate.blade.php and place the code in it:

//recaptchacreate.blade.php

<html lang=”en”>

<head>

ย ย ย  <title>reCAPTCHA Code in Laravel</title>

ย ย ย  <link rel=”stylesheet” href=”{{asset(‘css/app.css’)}}”>

ย ย ย  <link href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css” rel=”stylesheet”>ย ย 

ย ย ย  <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js”></script>ย 

ย ย ย  <script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>ย 

</head>

<body>

<div class=”container”>

ย ย ย ย ย  <h2>reCAPTCHA Code in Laravel</h2><br/>

ย ย ย ย ย  @if ($errors->any())

ย ย ย ย ย  <div class=”alert alert-danger”>

ย ย ย ย ย ย ย ย ย  <ul>

ย ย ย ย ย ย ย ย ย ย ย ย ย  @foreach ($errors->all() as $error)

ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  <li>{{ $error }}</li>

ย ย ย ย ย ย ย ย ย ย ย ย ย  @endforeach

ย ย ย ย ย ย ย ย ย  </ul>

ย ย ย ย ย  </div><br />

ย ย ย ย ย  @endif

ย ย ย ย ย  <form method=”post” action=”{{url(‘store’)}}”>

ย ย ย ย ย ย ย  @csrf

ย ย ย ย ย ย ย  <div class=”row”>

ย ย ย ย ย ย ย ย ย  <div class=”col-md-4″></div>

ย ย ย ย ย ย ย ย ย  <div class=”form-group col-md-4″>

ย ย ย ย ย ย ย ย ย ย ย  <label for=”Name”>Name:</label>

ย ย ย ย ย ย ย ย ย ย  ย <input type=”text” class=”form-control” name=”name”>

ย ย ย ย ย ย ย ย ย  </div>

ย ย ย ย ย ย ย  </div>

ย ย ย ย ย ย ย  <div class=”row”>

ย ย ย ย ย ย ย ย ย  <div class=”col-md-4″></div>

ย ย ย ย ย ย ย ย ย ย ย  <div class=”form-group col-md-4″>

ย ย ย ย ย ย ย ย ย ย ย ย ย  <label for=”Email”>Email:</label>

ย ย ย ย ย ย ย ย ย ย ย ย ย  <input type=”text” class=”form-control” name=”email”>

ย ย ย ย ย ย ย ย ย ย ย  </div>

ย ย ย ย ย ย ย ย ย  </div>

ย ย ย ย ย ย ย  <div class=”row”>

ย ย ย ย ย ย ย ย ย  <div class=”col-md-4″></div>

ย ย ย ย ย ย ย ย ย ย ย  <div class=”form-group col-md-4″>

ย ย ย ย ย ย ย ย ย ย ย ย ย  <label for=”Password”>Password:</label>

ย ย ย ย ย ย ย ย ย ย ย ย ย  <input type=”password” class=”form-control” name=”password”>

ย ย ย ย ย ย ย ย ย ย ย  </div>

ย ย ย ย ย ย ย ย ย  </div>

ย ย ย ย ย ย ย  <div class=”row”>

ย ย ย ย ย ย ย ย ย  <div class=”col-md-4″></div>

ย ย ย ย ย ย ย ย ย  <div class=”form-group col-md-4″>

ย ย ย ย ย ย ย ย ย  <label for=”ReCaptcha”>Recaptcha:</label>

ย ย ย ย ย ย ย ย ย  {!! NoCaptcha::renderJs() !!}

ย ย ย ย ย ย ย ย ย  {!! NoCaptcha::display() !!}

ย ย ย ย ย ย ย ย ย ย ย  </div>

ย ย ย ย ย ย ย  </div>

ย ย ย ย ย ย ย ย ย  <div class=”col-md-4″></div>

ย ย ย ย ย ย ย ย ย  <div class=”form-group col-md-4″>

ย ย ย ย ย ย ย ย ย ย ย  <button type=”submit” class=”btn btn-success”>Submit</button>

ย ย ย ย ย ย ย ย ย  </div>

ย ย ย ย ย ย ย  </div>

ย ย ย ย ย  </form>

ย ย ย  </div>

</body>

</script>

</html>

Now, you need to develop the Laravel server by using the below-mentioned command:

PHP artisan serve

If you enter incorrect reCaptcha code, then it will show errors-

Now, you have successfully generated the Google Recaptcha code in Laravel.

Final Words

So, it is clear that Recaptcha is used by website owners to differentiate between bots and human users. You can generate Google Recaptcha code in Larvel in an easy way. Best of Luck!

Author Bio

Jack Calder is a WordPress Developer, associated with Stellen Infotech one of the best Web Development & Digital Marketing Company around the globe. He has a lot of experience in development custom WordPress Themes. He has delivered a numerous range of quality Websites related to WordPress. She has a strong passion for writing useful and insights about WordPress tips and tricks.

Related Posts:

  • Search_SocialShare_7gpZ6Zv.width-1300 (2)
    Google Tests AI Overview Opt-Out Tools For Site Owners
  • google_logo_1
    Google Building A Shielded Email Feature to Help…
  • google opal
    Google Integrates Opal Vibe-Coding Tool Into Gemini
  • deepkeep
    New CLI Tool Exposes Blind Spot in AI Agent Security…
  • Frame_2147223720.width-1200.format-webp
    Vibe Coding is Now Available in Google's AI Studio
  • Digital Cloud Networking
    Demystifying Serverless Computing: Understanding And…
  • Link Acquisition Strategies
    15 Link Acquisition Strategies That Actually Work in 2025
  • assets_task_01jrfxkvwqeexbx349fmgw9baz_img_0
    Schema Markup in WordPress: A Step-by-Step Guide to…

Discover more from TechBooky

Subscribe to get the latest posts sent to your email.

Tags: codedevelopergooglegoogle recaptchalaravellaravel developerlaravel programmingrecaptcharesearchtipstutorialwebsite
Contributor

Contributor

Posts by contributors. You can send in a post to be reviewed and published to info@techbooky.com

BROWSE BY CATEGORIES

Receive top tech news directly in your inbox

subscription from
Loading

Freshly Squeezed

  • Elon Musk Hits $1.1 Trillion as SpaceX Surpasses $2 Trillion Valuation June 13, 2026
  • SpaceX Prices Record $75 Billion IPO as Elon Musk Nears Trillionaire Status June 12, 2026
  • DoorDash Launches AI Chatbot for Food Orders June 12, 2026
  • Pool Launches App That Makes Screenshots More Useful June 12, 2026
  • Deezer Launches Tool to Detect AI-Generated Music June 12, 2026
  • Coinbase Introduces Platform for Agents to Trade Assets and Buy Premium Insights June 12, 2026
  • Meta Expands Edits App With AI Features and Desktop Access June 12, 2026
  • Ready-made LMS and custom development. Pros and cons of each path. June 11, 2026
  • TELCOs Pay 75 Million Users For Poor Network Service June 10, 2026
  • Anthropic Launches Claude Fable 5, Bringing Mythos-Class AI to the Public June 10, 2026
  • Discord Data Breach Reportedly Impacts Over 10 Million Users June 10, 2026
  • TikTok Removed Four Million Videos & Disrupted 86,000 LIVE Sessions In Nigeria June 10, 2026

Browse Archives

June 2026
MTWTFSS
1234567
891011121314
15161718192021
22232425262728
2930 
« May    

Quick Links

  • About TechBooky
  • Advertise Here
  • Contact us
  • Submit Article
  • Privacy Policy
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
  • African
  • Artificial Intelligence
  • Gadgets
  • Metaverse
  • Tips
  • AI Search
  • About TechBooky
  • Advertise Here
  • Submit Article
  • Contact us

ยฉ 2025 Designed By TechBooky Elite

Discover more from TechBooky

Subscribe now to keep reading and get access to the full archive.

Continue reading

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.