PHPackages                             syspay/login-recaptcha-bundle - 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. [Security](/categories/security)
4. /
5. syspay/login-recaptcha-bundle

ActiveSymfony-bundle[Security](/categories/security)

syspay/login-recaptcha-bundle
=============================

Login Recaptcha Bundle for Symfony 3

v2.1.2(7y ago)66.1k3[1 issues](https://github.com/syspay/login-recaptcha-bundle/issues)[1 PRs](https://github.com/syspay/login-recaptcha-bundle/pulls)MITPHPPHP &gt;=5.5.1

Since Mar 5Pushed 7y ago4 watchersCompare

[ Source](https://github.com/syspay/login-recaptcha-bundle)[ Packagist](https://packagist.org/packages/syspay/login-recaptcha-bundle)[ Docs](https://github.com/syspay/login-recaptcha-bundle)[ RSS](/packages/syspay-login-recaptcha-bundle/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (6)Versions (10)Used By (0)

Login reCAPTCHA Bundle
======================

[](#login-recaptcha-bundle)

[![License](https://camo.githubusercontent.com/a6d69205448674ebf32e3f082464405f8442c3951054349b81ed36f72f005ceb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7379737061792f6c6f67696e2d7265636170746368612d62756e646c652e737667)](https://packagist.org/packages/syspay/login-recaptcha-bundle)

- Packagist Page:
- Repository:
- Version: 2.1.2
- License: MIT, see [LICENSE](LICENSE)

Description
-----------

[](#description)

Login reCAPTCHA Bundle makes it easy for you to integrate Google reCAPTCHA inside login forms in Symfony 3.

Installation
------------

[](#installation)

This symfony bundle is available on Packagist as [`syspay/login-recaptcha-bundle`](https://packagist.org/packages/syspay/login-recaptcha-bundle) and can be installed either by running the `composer require` command or adding the library to your `composer.json`.

To add this dependency using the command, run the following from within your project directory:

```
composer require syspay/login-recaptcha-bundle

```

Alternatively, add the dependency directly to your `composer.json` file:

```
"require": {
    "syspay/login-recaptcha-bundle": "^2.1"
}
```

After composer installation go to your `AppKernel.php` file and add the following line inside `registerBundles()`:

```
$bundles = [
    ...
    new LoginRecaptcha\Bundle\LoginRecaptchaBundle(),
];

```

Configuration
-------------

[](#configuration)

To use this functionality you have to use `form_login_captcha` instead of `form_login` in your `security.yml` file. This new security listener factory has all the same options as `form_login` but it has a required new option called `google_recaptcha_secret` where you have to enter your Google reCAPTCHA secret key.

```
form_login_captcha:
    login_path: login
    check_path: login_check
    username_parameter: "login_form[username]"
    password_parameter: "login_form[password]"
    csrf_parameter: "login_form[_token]"
    default_target_path: homepage
    google_recaptcha_secret: XXXXXXXXXXXXXXXX_XXXX_XXXXXXXXXXXXXXXXXXX

```

From then on your login form expects a new post parameter called `g-recaptcha-response` which is created by any reCAPTCHA plugin. Then the bundle authenticates the response by using Google's own reCAPTCHA package.

Validating reCAPTCHA only after several failed attempts
-------------------------------------------------------

[](#validating-recaptcha-only-after-several-failed-attempts)

By default the bundle always checks for the post parameter `g-recaptcha-response` but this can be annoying on users as they'd have to input the reCAPTCHA everytime they login, therefore there is an option to only validate the reCAPTCHA after several failed logins from an ip range. This option needs a couple of extra configurations on your end. The way it works is that everytime there is a failed login a listener is called to create or increment a particular key in your cache client.

All you have to do is to set up your cache client example redis and declare a particular service that the bundle expects. This service needs to implement the class `LoginRecaptcha\Bundle\Client\CacheClientInterface`. A Predis extension is already provided in the bundle under the name `LoginRecaptcha\Bundle\Client\PredisClient`. After creating your class or using the provided one declare the following service in your `app/services.yml`. It is very important that the service name is `login_recaptcha.cache_client`.

```
    login_recaptcha.cache_client:
        class: LoginRecaptcha\Bundle\Client\PredisClient
        arguments:
            - '@snc_redis.default'
            - '%attempts%
            - '%expiry%

```

In my case `@snc_redis.default` is my cache service. The second argument is the number of failed attempts you want to verify the reCATPCHA after and the third argument is how long you want the key to stay in your cache.

After this all you have to do is add the option `always_captcha: false` under `form_login_captcha` in your `security.yml` file.

```
form_login_captcha:
    login_path: login
    check_path: login_check
    username_parameter: "login_form[username]"
    password_parameter: "login_form[password]"
    csrf_parameter: "login_form[_token]"
    default_target_path: homepage
    google_recaptcha_secret: XXXXXXXXXXXXXXXX_XXXX_XXXXXXXXXXXXXXXXXXX
    always_captcha: false

```

To check on the front end whether you should be showing the reCAPTCHA widget or not you need to inject the service `login_recaptcha.captcha_login_form.manager` in your controller and call the function `isCaptchaNeeded()` which takes the `$request->getClientIp()`. This returns `true` or `false` which you can then pass as a variable to twig.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~82 days

Total

5

Last Release

2667d ago

Major Versions

v1.0 → v2.02018-03-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/674574a771440c778973e1d9f422ec37f5abacc5d54f124103c6fd2cbf534ee6?d=identicon)[syspay](/maintainers/syspay)

![](https://www.gravatar.com/avatar/d3b347f6206b839df0043ec8a844978f0c6db3c8189d6589018ff440b1988c41?d=identicon)[Gabb1995](/maintainers/Gabb1995)

---

Top Contributors

[![Gabb1995](https://avatars.githubusercontent.com/u/20728259?v=4)](https://github.com/Gabb1995 "Gabb1995 (2 commits)")[![xdimedrolx](https://avatars.githubusercontent.com/u/1534427?v=4)](https://github.com/xdimedrolx "xdimedrolx (1 commits)")

---

Tags

formloginrecaptchasymfonysymfony-bundlesymfony2symfony3

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/syspay-login-recaptcha-bundle/health.svg)

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

###  Alternatives

[elnur/blowfish-password-encoder-bundle

Blowfish (bcrypt) based password encoder for Symfony2

61129.6k](/packages/elnur-blowfish-password-encoder-bundle)[vipx/bot-detect-bundle

Symfony VipxBotDetectBundle

14229.6k1](/packages/vipx-bot-detect-bundle)[leaseweb/secure-controller-bundle

Provide '@Secure' annotation to secure actions in controllers by specifying required roles

14126.4k](/packages/leaseweb-secure-controller-bundle)[rezzza/security-bundle

Signed requests check

1753.6k](/packages/rezzza-security-bundle)

PHPackages © 2026

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