Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

recaptcha

reCAPTCHA Validator for Laravel 5

Subscribe to updates I use recaptcha


Statistics on recaptcha

Number of watchers on Github 644
Number of open issues 33
Average time to close an issue about 1 month
Main language PHP
Average time to merge a PR 16 days
Open pull requests 16+
Closed pull requests 15+
Last commit about 2 years ago
Repo Created over 6 years ago
Repo Last Updated over 1 year ago
Size 72 KB
Organization / Authorgreggilbert
Latest Release2.1.1
Contributors18
Page Updated
Do you use recaptcha? Leave a review!
View open issues (33)
View recaptcha activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating recaptcha for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Recaptcha

A reCAPTCHA Validator for Laravel 5.

(Looking for a Laravel 4 version? Pull the latest 1.x tag. For Laravel 5.0, pull the latest 2.0 tag.)

LOOKING FOR MAINTAINER(S)

tldr; I don't really have time to maintain this package on my own, so I'm looking for help. If you're interested, leave a note on #146. Thanks!

Installation

Add the following line to the require section of composer.json:

{
    "require": {
        "greggilbert/recaptcha": "dev-master"
    }
}

Setup

  1. In /config/app.php, add the following to providers:
  Greggilbert\Recaptcha\RecaptchaServiceProvider::class,

and the following to aliases:

  'Recaptcha' => Greggilbert\Recaptcha\Facades\Recaptcha::class,
  1. Run php artisan vendor:publish --provider="Greggilbert\Recaptcha\RecaptchaServiceProvider".
  2. In /config/recaptcha.php, enter your reCAPTCHA public and private keys.
    • If you are not using the most recent version of reCAPTCHA, set version to 1.
    • If you are upgrading to v2 of reCAPTCHA, note that your keys from the previous version will not work, and you need to generate a new set in the reCAPTCHA admin.
  3. The package ships with a default validation message, but if you want to customize it, add the following line into resources/lang/[lang]/validation.php:
      'recaptcha' => 'The :attribute field is not correct.',

Usage

v2 (No Captcha)

  1. In your form, use {!! Recaptcha::render() !!} to echo out the markup.
  2. In your validation rules, add the following:
    $rules = [
        // ...
        'g-recaptcha-response' => 'required|recaptcha',
    ];

v1 (Legacy)

  1. In your form, use {!! Recaptcha::render() !!} to echo out the markup.
  2. In your validation rules, add the following:
    $rules = [
        // ...
        'recaptcha_response_field' => 'required|recaptcha',
    ];

It's also recommended to add required when validating.

Customization

reCAPTCHA v2 allows for customization of the widget through a number of options, listed at the official documentation. You can configure the output of the captcha through six allowed keys: theme, type, lang, callback, tabindex and expired-callback.

In the config file, you can create an options array to set the default behavior. For example:

    // ...
    'options' => [
        'lang' => 'ja',
    ],

would default the language in all the reCAPTCHAs to Japanese. If you want to further customize, you can pass options through the render option:

echo Recaptcha::render([ 'lang' => 'fr' ]);

Options passed into Recaptcha::render will always supercede the configuration.

Language

To change the language of the captcha, simply pass in a language as part of the options:

    'options' => [
        'lang' => 'fr',
    ],

For a list of valid language codes, consulting the official documentation.

Custom template

Alternatively, if you want to set a default template instead of the standard one, you can use the config:

    // ...
    'template' => 'customCaptcha',

or you can pass it in through the Form option:

echo Recaptcha::render([ 'template' => 'customCaptcha' ]);

v1 customization

For the v1 customization options, consult the old documentation and apply accordingly.

Limitation

Because of Google's way of displaying the reCAPTCHA, this package won't work if you load your form from an AJAX call. If you need to do it, you should use one of the alternate methods provided by Google.

recaptcha open issues Ask a question     (View All Issues)
  • almost 3 years reCaptcha failing after succeeds "The given data failed to pass validation"
  • over 3 years Recaptcha::render() should not return a view that is cast to a string
  • almost 4 years Add 'size' attribute
  • about 4 years Message Language
  • about 4 years Secure token
  • over 4 years Resizing
  • over 4 years Multiple instances of recaptcha?
recaptcha open pull requests (View All Pulls)
  • Allow private & public key config value to be a Closure
  • View set key
  • Extend validator only when it is actually resolved
  • add lumen support
  • Added the Secure Token option [#85]
  • Secure token, with changes.
  • Proxy setting functionality for Curl
  • Support for languages, covers #87
  • Friends don't let friends use dev-master
  • Added size param to dataParameterKeys
  • Fix inverted parameter on curl_verify option check
  • Allow multiple reCaptchas on single page
  • by the docs it should be async
  • Added merge configuration
  • Added Laravel package discovery for laravel 5.5
  • Added optional parameter "size" to allow use of both default and comp…
recaptcha questions on Stackoverflow (View All Questions)
  • Recaptcha does not display on localhost
  • Google ReCaptcha - Missing input response
  • Recaptcha 1.0 vs 2.0 in C#
  • g-recaptcha-response with AJAX
  • Google's reCaptcha to reduce spam
  • reCaptcha ERROR: Invalid domain for site key in Google Server
  • reCaptcha (privacy and terms) location
  • Working example of new recaptcha with Rails?
  • Recaptcha throwing error Unable to access error message
  • Google reCaptcha reset doesn't work
  • Google reCaptcha on Cordova(phonegap)
  • google recaptcha, check captcha using ajax and send form data to another page
  • How to change captcha error language from Contact form 7 google recaptcha?
  • ZfcUser ReCaptcha v2
  • CSS and Recaptcha
  • Does Google reCaptcha use session?
  • Is there a way to use Google Recaptcha in a Phonegap app?
  • Google ReCaptcha - Displaying text images instead of food images
  • Business level IP's can't pass reCAPTCHA
  • Google V2 recaptcha not show visual images by default
  • New Google ReCaptcha not posting/receiving 'g-recaptcha-response'
  • Drupal 7 recaptcha is not working in mobile iphone 4,5. How to solve suggest me solutions?
  • Google reCaptcha v2.0 in php
  • contact form 7 wordpress not sending mails when use recaptcha extension
  • override sessions controller in Devise to get Recaptcha after 3 failed attempts
  • Google recaptcha admin panel not showing domains which are added
  • reCAPTCHA message within the form: "This reCAPTCHA is currently running on localhost."
  • Google Recaptcha not working in iOS webview
  • New reCaptcha with jQuery Validation Plugin
  • javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed google recaptcha
recaptcha list of languages used
Other projects in PHP