The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

No Captcha

anhskohbo/no-captcha image

No Captcha stats

Downloads
4.8M
Stars
1,713
Open Issues
48
Forks
236

View on GitHub →

No CAPTCHA reCAPTCHA For Laravel.

No CAPTCHA reCAPTCHA Package for Laravel

The No CAPTCHA reCAPTCHA package provides an easy-to-integrate solution to protect your Laravel applications from spam and abuse. This package leverages Google's reCAPTCHA service to differentiate between human users and bots, implementing the latest security measures to safeguard your forms.

Key Features

  • Simple Integration: Quick setup for Laravel applications, with support for Laravel 5.5's auto-discovery feature.
  • Flexible Configuration: Easy customization of reCAPTCHA theme, size, and callback directly from your views.
  • Invisible CAPTCHA Support: Allows the use of Invisible reCAPTCHA for a seamless user experience.
  • Language Support: Localize CAPTCHA prompts to the preferred language of your audience.
  • Testing Support: Facilitates the mocking of CAPTCHA responses during application testing to ensure smooth CI/CD integration.

Installation

Install the package via Composer:

composer require anhskohbo/no-captcha

Setup for Laravel 5 and above

For Laravel versions prior to 5.5, register the service provider and facade in your app/config/app.php:

'providers' => [
Anhskohbo\NoCaptcha\NoCaptchaServiceProvider::class,
];
 
'aliases' => [
'NoCaptcha' => Anhskohbo\NoCaptcha\Facades\NoCaptcha::class,
];

Publish the config file with:

php artisan vendor:publish --provider="Anhskohbo\NoCaptcha\NoCaptchaServiceProvider"

Configuration

Add your site and secret keys to your .env file:

NOCAPTCHA_SECRET=your-secret-key
NOCAPTCHA_SITEKEY=your-site-key

Obtain your keys from Google's reCAPTCHA admin console.

Usage

Rendering CAPTCHA

To include reCAPTCHA in your forms:

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

Customize it with options like theme or size:

{!! NoCaptcha::display(['data-theme' => 'dark']) !!}

For Invisible reCAPTCHA:

{!! NoCaptcha::displaySubmit('my-form-id', 'Submit Now!', ['data-theme' => 'dark']) !!}

Validation

Add reCAPTCHA validation rules to your form requests:

$validate = Validator::make(Input::all(), [
'g-recaptcha-response' => 'required|captcha'
]);

Testing

Mock CAPTCHA response in your Laravel tests:

NoCaptcha::shouldReceive('verifyResponse')
->once()
->andReturn(true);

Without Laravel

For non-Laravel PHP projects, you can still utilize this package by including it with Composer and using it directly in your forms.

<?php
require_once "vendor/autoload.php";
 
$captcha = new \Anhskohbo\NoCaptcha\NoCaptcha('your-secret', 'your-sitekey');
 
if (!empty($_POST)) {
var_dump($captcha->verifyResponse($_POST['g-recaptcha-response']));
exit();
}
 
echo $captcha->display();
echo $captcha->renderJs();
?>

Contribution

Contributions are welcome via pull requests on GitHub.

This package makes integrating Google's reCAPTCHA into Laravel applications straightforward and customizable, with support for advanced features like Invisible CAPTCHA and localization. Perfect for developers looking to enhance security without compromising user experience.

anhskohbo photo

PHP Developer

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Anhskohbo No Captcha Related Articles

5 Ways of Battling Form Spam image

5 Ways of Battling Form Spam

Read article
reCAPTCHA Packages for Laravel image

reCAPTCHA Packages for Laravel

Read article
Invisible reCAPTCHA Integration with Laravel image

Invisible reCAPTCHA Integration with Laravel

Read article
Laravel No CAPTCHA reCAPTCHA image

Laravel No CAPTCHA reCAPTCHA

Read article
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
LoadForge logo

LoadForge

Scalable load testing for web apps & APIs. Simulate real-world traffic and identify breaking points and performance limits with powerful, scalable load tests designed for Laravel.

LoadForge
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech