PHPackages                             geekybones/fraud-defense-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. geekybones/fraud-defense-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

geekybones/fraud-defense-bundle
===============================

Symfony bundle for Google reCAPTCHA Enterprise (forms, validation, score and checkbox widgets)

1.0.1(1mo ago)029MITPHPPHP ^8.2

Since May 26Pushed 1mo agoCompare

[ Source](https://github.com/geekybones/fraud-defense-bundle)[ Packagist](https://packagist.org/packages/geekybones/fraud-defense-bundle)[ RSS](/packages/geekybones-fraud-defense-bundle/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (15)Versions (3)Used By (0)

Fraud Defense Bundle
====================

[](#fraud-defense-bundle)

Symfony integration for [Google reCAPTCHA Enterprise](https://cloud.google.com/recaptcha-enterprise/docs) with support for standard bot protection, Transaction Defense, and SMS toll-fraud Defense. By [GeekyBones](https://geekybones.com).

Package`geekybones/fraud-defense-bundle`PHP`^8.2`Symfony`^7.0` or `^8.0`LicenseMIT---

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

[](#installation)

```
composer require geekybones/fraud-defense-bundle
```

If Symfony Flex did not register the bundle automatically, add it to `config/bundles.php`:

```
GeekyBones\FraudDefenseBundle\FraudDefenseBundle::class => ['all' => true],
```

---

Google Cloud setup
------------------

[](#google-cloud-setup)

1. Enable the **reCAPTCHA Enterprise API** in your GCP project.
2. Create one or more site keys for your domain (score key for invisible checks, checkbox key for the "I'm not a robot" widget).
3. Create an **API key** restricted to the reCAPTCHA Enterprise API.

For Transaction Defense and SMS Defense, additional console steps are required — see their dedicated guides.

---

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

[](#configuration)

Add environment variables:

```
FRAUD_DEFENSE_PROJECT_ID=your-gcp-project-id
FRAUD_DEFENSE_API_KEY=your-api-key
FRAUD_DEFENSE_SITE_KEY=your-score-site-key
# FRAUD_DEFENSE_CHECKBOX_SITE_KEY=your-checkbox-site-key  # only if using checkbox widget
```

Create `config/packages/fraud_defense.yaml`:

```
fraud_defense:
    project_id: '%env(FRAUD_DEFENSE_PROJECT_ID)%'
    api_key:    '%env(FRAUD_DEFENSE_API_KEY)%'
    site_key:   '%env(FRAUD_DEFENSE_SITE_KEY)%'
    min_score:  0.5
```

Standard reCAPTCHA (`RecaptchaType`) works with this minimal config. Enable `transaction_defense` or `sms_defense` only when you need those flows.

See [configuration.md](docs/configuration.md) for all options.

---

Usage
-----

[](#usage)

### Standard form protection

[](#standard-form-protection)

```
use GeekyBones\FraudDefenseBundle\Form\RecaptchaType;

$builder->add('captcha', RecaptchaType::class, [
    'action' => 'login',
]);
```

```
{{ form_row(form.captcha) }}
```

Validation runs automatically on form submit. No controller changes needed.

### Programmatic

[](#programmatic)

Inject the interface and call `assess()` directly — useful in APIs and controllers without forms:

```
use GeekyBones\FraudDefenseBundle\Defense\Contract\RecaptchaAssessmentInterface;
use GeekyBones\FraudDefenseBundle\Defense\DefenseAssessmentException;

public function __construct(
    private readonly RecaptchaAssessmentInterface $recaptcha,
) {}

try {
    $result = $this->recaptcha->assess(
        token: $request->request->get('recaptcha_token'),
        action: 'login',
    );
} catch (DefenseAssessmentException $e) {
    // API error, invalid/expired token, or incomplete response
}

if (!$result->hasPassed()) {
    // score too low, action mismatch, or hostname mismatch
}
```

---

Form types
----------

[](#form-types)

Form typeWhen to useRequires`RecaptchaType`Login, registration, contact — bot detectionDefault config`TransactionRecaptchaType`Checkout, payment — fraud risk scoring`transaction_defense.enabled: true``SmsRecaptchaType`SMS OTP — toll-fraud detection`sms_defense.enabled: true`All three share the same Twig widget (`{{ form_row(form.captcha) }}`).

---

Documentation
-------------

[](#documentation)

GuideContents[configuration.md](docs/configuration.md)All YAML options, environment variables, per-case examples[recaptcha.md](docs/recaptcha.md)Standard reCAPTCHA: form setup, script loading, programmatic usage[transaction-defense.md](docs/transaction-defense.md)Transaction Defense: GCP setup, form, context reference, troubleshooting[sms-defense.md](docs/sms-defense.md)SMS Defense: GCP setup, form, programmatic usage[architecture.md](docs/architecture.md)Internal code structure and request flow

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance88

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

59d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/26045293?v=4)[Manoj K](/maintainers/manojx)[@manojx](https://github.com/manojx)

![](https://avatars.githubusercontent.com/u/36783929?v=4)[GeekyBones](/maintainers/geekybones)[@geekybones](https://github.com/geekybones)

---

Top Contributors

[![manojxio](https://avatars.githubusercontent.com/u/7418454?v=4)](https://github.com/manojxio "manojxio (4 commits)")

---

Tags

symfonybundlegooglerecaptcharecaptcha-enterprise

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/geekybones-fraud-defense-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/geekybones-fraud-defense-bundle/health.svg)](https://phpackages.com/packages/geekybones-fraud-defense-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M400](/packages/easycorp-easyadmin-bundle)

PHPackages © 2026

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