Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

laravel-recaptcha

> 后端框架
Open source

Google ReCaptcha package for Laravel

517 stars0 likes4 views
WebsiteGitHub

About

Google ReCaptcha package for Laravel

Laravel ReCAPTCHA is a very simply-to-use Laravel 5 package to embed Google reCAPTCHA in your application.

What is reCAPTCHA?

Google developers says: "reCAPTCHA protects you against spam and other types of automated abuse. Here, we explain how to add reCAPTCHA to your site or application."

You can find further info at Google reCAPTCHA Developer's Guide

reCAPTCHA available versions

At this moment there are 3 versions available (for web applications):

  • v3, the latest (reCAPTCHA v3)
  • v2 checkbox or simply reCAPTCHA v2 (reCAPTCHA v2)
  • v2 invisible (Invisible reCAPTCHA)

Get your key first!

First of all you have to create your own API keys here

Follow the instructions and at the end of the process you will find Site key and Secret key. Keep them close..you will need soon!

System requirements

Package version reCaptcha version PHP version Laravel version
6.1 v3, v2 Invisible, v2 Checkbox 7.3 or greater 7, 8, 9, 10, 11
6.0 v3, v2 Invisible, v2 Checkbox 7.3 or greater 7, 8, 9, 10
5.x v3, v2 Invisible, v2 Checkbox 7.3 or greater 7, 8, 9
4.2.x to 4.4.x v3, v2 Invisible, v2 Checkbox 7.1 or greater 5.5 or greater, 6, 7, 8
4.1.x v3, v2 Invisible, v2 Checkbox 7.1 or greater 5.5 or greater, 6, 7
4.0.x v3, v2 Invisible, v2 Checkbox 7.1 or greater 5.5 or greater, 6
3.x v3, v2 Invisible, v2 Checkbox 7.1 or greater 5.5 or greater, 6 (*)
2.x v2 Invisible, v2 Checkbox 5.5.9, 7.0 or greater 5.0 or greater

(*) Version 3.6.1 is Laravel 6 ready

Composer

You can install the package via composer:

bash
$ composer require biscolab/laravel-recaptcha

Laravel 5.5 (or greater) uses package auto-discovery, so doesn't require you to manually add the Service Provider, but if you don't use auto-discovery ReCaptchaServiceProvider must be registered in config/app.php:

php
'providers' => [
    ...
    Biscolab\ReCaptcha\ReCaptchaServiceProvider::class,
];

You can use the facade for shorter code. Add ReCaptcha to your aliases:

php
'aliases' => [
    ...
    'ReCaptcha' => Biscolab\ReCaptcha\Facades\ReCaptcha::class,
];

Publish package

Create config/recaptcha.php configuration file using the following artisan command:

bash
$ php artisan vendor:publish --provider="Biscolab\ReCaptcha\ReCaptchaServiceProvider"

Set the environment

Add your API Keys

Open .env file and set RECAPTCHA_SITE_KEY and RECAPTCHA_SECRET_KEY:

php
# in your .env file
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=
RECAPTCHA_SKIP_IP=

RECAPTCHA_SKIP_IP (since v5.2.0, not required, CSV format ) allows you to add a list of IP/CIDR (netmask included). It will be the value of skip_ip

The following environment variables have been removed!!! Now only sensitive informations as API keys are allowed as environment variables, that means you have to set configuration values in config/recaptcha.php

  • RECAPTCHA_DEFAULT_VERSION
  • RECAPTCHA_CURL_TIMEOUT
  • RECAPTCHA_DEFAULT_VALIDATION_ROUTE
  • RECAPTCHA_DEFAULT_TOKEN_PARAMETER_NAME
  • RECAPTCHA_DEFAULT_LANGUAGE

Complete configuration

Open config/recaptcha.php configuration file and set version:

…
Key Type Description Default
api_site_key and api_secret_key string reCAPTCHA keys you have to create in order to perform Google API authentication. For more information about Site Key and Secret Key please visit Google reCAPTCHA developer documentation ''
version string indicates the reCAPTCHA version (supported: v3|v2|invisible). Get more info about reCAPTCHA version at https://developers.google.com/recaptcha/docs/versions 'v2'
curl_timeout int the maximum number of seconds to allow cURL functions to execute 10
skip_ip array | string a whitelist of IP addresses (array or CSV) that, if recognized, disable the reCAPTCHA validation (return always true) and if you embed JS code in blade (view) file NO validation call will be performed []
default_validation_route string the route called via javascript built-in validation script (v3 only) 'biscolab-recaptcha/validate'
default_token_parameter_name string the name of "token" GET parameter sent to default_validation_route to be validated (v3 only) 'token'
default_language string the default language code. It has no effect with v3. See https://developers.google.com/recaptcha/docs/language for further information null
default_form_id string the default form ID. Only for "invisible" reCAPTCHA 'biscolab-recaptcha-invisible-form'
explicit bool deferring the render can be achieved by specifying your onload callback function and adding parameters to the JavaScript resource. It has no effect with v3 and invisible (supported values: true|false) false
api_domain string customize API domain. Default value is 'www.google.com', but, if not accessible you ca set that value to 'www.recaptcha.net'. More info about Can I use reCAPTCHA globally? 'www.google.com'
empty_message bool set default error message to null false
error_message_key string set default error message translation key 'validation.recaptcha'

(array) tag_attributes

Key Type Description Default
tag_attributes.theme string the color theme of the widget. (supported values: "light"|"dark") 'light'
tag_attributes.size string the size of the widget. (supported values: "normal"|"compact") 'normal'
tag_attributes.tabindex int the tabindex of the widget and challenge 0
tag_attributes.callback string the name of your callback function, executed when the user submits a successful response. The g-recaptcha-response token is passed to your callback null
tag_attributes.expired-callback string the name of your callback function, executed when the reCAPTCHA response expires and the user needs to re-verify null
tag_attributes.error-callback string the name of your callback function, executed when reCAPTCHA encounters an error (usually network connectivity) and cannot continue until connectivity is restored. If you specify a function here, you are responsible for informing the user that they should retry null

DO NOT SET tag_attributes.callback, tag_attributes.expired-callback, tag_attributes.error-callback to biscolabOnloadCallback. biscolabOnloadCallback is the default JavaScript callback function called when explicit is set to true and widget onload event is fired.

Here you can find further details about tag_attributes.* https://developers.google.com/recaptcha/docs/display#render_param

Reload config cache file

!!! IMPORTANT !!! Every time you change some configuration run the following shell command:

bash
$ php artisan config:cache

Have you updated?

If you are migrating from an older version check your `config/recaptcha

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPcheckboxdata-validationform-validationgoogle-recaptcha

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架