PHPackages                             marwelln/recaptcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. marwelln/recaptcha

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

marwelln/recaptcha
==================

Recaptcha that supports Google's new "no captcha recaptcha" (with Laravel support)

v2.0.0(11y ago)1117.1k↓67.1%3MITPHPPHP &gt;=5.4.0

Since Dec 5Pushed 11y ago3 watchersCompare

[ Source](https://github.com/Marwelln/recaptcha)[ Packagist](https://packagist.org/packages/marwelln/recaptcha)[ RSS](/packages/marwelln-recaptcha/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)DependenciesVersions (4)Used By (0)

What is reCAPTCHA?
==================

[](#what-is-recaptcha)

> reCAPTCHA is a free service to protect your website from spam and abuse. reCAPTCHA uses an advanced risk analysis engine and adaptive CAPTCHAs to keep automated software from engaging in abusive activities on your site. It does this while letting your valid users pass through with ease.

This package gives you an easy validation in PHP for Google's new (december 2014) reCAPTCHA. It allows you to validate if you are a human or robot with just a simple mouse click. See [this Youtube link](https://www.youtube.com/watch?v=jwslDn3ImM0&channel=GoogleWebmasterHelp) for a brief look at how it works.

Installation
============

[](#installation)

You can install this package by using [Composer](https://getcomposer.org/).

- Option 1: Add `"marwelln/recaptcha" : "~2.0"` to your `composer.json` file and run `composer update`.
- Option 2: Run `composer require marwelln/recaptcha:dev-master`

### Laravel

[](#laravel)

If you're using Laravel, you need to `'Marwelln\Recaptcha\RecaptchaServiceProvider'` to your `providers` array in `config/app.php`.

Recaptcha keys
==============

[](#recaptcha-keys)

To use reCAPTCHA, you need to have a `site key` and a `secret key`. [Click here](https://www.google.com/recaptcha/admin#createsite) to setup a domain and get your keys.

The `site key` is using for the widget and the `secret key` is used to validate the response we get from Google.

Front-end usage
===============

[](#front-end-usage)

To display the reCAPTCHA widget, you first need to include their javascript file on your site. Put the following code at the bottom of your site.

```

```

After that, you need to add a `div` where you want to display the widget. The required attributes is `class` with a value of `g-recaptcha` and `data-sitekey` with a value of your site key. *Don't have a key? [Get one over here](https://www.google.com/recaptcha/admin#createsite).*

```

```

There are three optional attributes available for you to style and manage the widget. It's `data-theme`, `data-type` and `data-callback`. See Google's [configuration documentation](https://developers.google.com/recaptcha/docs/display#config) for up-to-date and more details about each attribute.

### Laravel

[](#laravel-1)

If your using Laravel, you can display the widget by including the available view file. This will include the script file and the div tag.

Laravel 5:

```
{!! View::make('recaptcha::display') !!}

```

Laravel 4:

```
{{ View::make('recaptcha::display') }}

```

Back-end usage
==============

[](#back-end-usage)

To validate the response we get from Google we use the `Marwelln\Recaptcha\Model` class.

```
$validator = new \Marwelln\Recaptcha\Model($_POST['g-recaptcha-response'], $secretKey);
$validated = $validator->validate();

$response = '';
if ( ! $validated) {
    $response .= '' . print_r($validator->errors(), true) . '';
}

$response .= 'Did I validate? ' . ($validated ? 'Yes.' : 'No.');

echo $response;

```

If you don't want to insert `$secretKey` everytime you want to validate the response, you can add an environment value with `RECAPTCHA_SECRETKEY` as key.

```
putenv('RECAPTCHA_SECRETKEY=my-recaptcha-secret-key');

$validator = new \Marwelln\Recaptcha\Model($_POST['g-recaptcha-response']);

```

### Laravel

[](#laravel-2)

Laravel validation is supported by using the `recaptcha` validation rule on `g-recaptcha-response`.

```
$rules = [
    'g-recaptcha-response' => 'required|recaptcha'
];

$validator = Validator::make(Input::all(), $rules);
$validated = $validator->passes();

$response = '';
if ( ! $validated) {
    $response .= '' . print_r($validator->errors()->all(), true) . '';
}

$response .= 'Did I validate? ' . ($validated ? 'Yes.' : 'No.');

return $response;

```

### Errors

[](#errors)

If `validate()` fails, you can get the errors by calling `$validator->errors()`. This will return an array with codes errors keys. See *Error code reference* at the [documenation website](https://developers.google.com/recaptcha/docs/verify).

If you are using **Laravel**, `errors()` will return an instance of `Illuminate\Support\MessageBag` with all errors translated.

Laravel configuration
=====================

[](#laravel-configuration)

There is not really a need to publish the configuration file. Both the `siteKey` and `secretKey` should be set in your environment file so it won't be available in your versioning system.

The only option available is to enable or disable curl. So if you're having trouble or don't have access to curl, you can publish the configuration file and change the `curl` value to false. We will then use `file_get_contents` instead.

Laravel 5:

```
php artisan vendor:publish

```

Laravel 4:

```
php artisan config:publish marwelln/recaptcha

```

See [Protecting Sensitive Configuration](http://laravel.com/docs/4.2/configuration#protecting-sensitive-configuration) if you don't know how to setup environment variables in Laravel 4.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Total

3

Last Release

4163d ago

Major Versions

1.x-dev → v2.0.02015-02-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e5e4d36e4b85e220991cbc37adec7a61b195172c53933bf0e3902a218be08eb?d=identicon)[Marwelln](/maintainers/Marwelln)

---

Top Contributors

[![Marwelln](https://avatars.githubusercontent.com/u/128591?v=4)](https://github.com/Marwelln "Marwelln (5 commits)")[![oriceon](https://avatars.githubusercontent.com/u/358823?v=4)](https://github.com/oriceon "oriceon (1 commits)")

### Embed Badge

![Health badge](/badges/marwelln-recaptcha/health.svg)

```
[![Health](https://phpackages.com/badges/marwelln-recaptcha/health.svg)](https://phpackages.com/packages/marwelln-recaptcha)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.3M17](/packages/kartik-v-yii2-password)[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
