PHPackages                             rvxlab/hcaptcha - 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. rvxlab/hcaptcha

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

rvxlab/hcaptcha
===============

hCaptcha for Laravel

5.2.0(2y ago)237.2k↓50%1[4 PRs](https://github.com/RVxLab/hcaptcha/pulls)MITPHPPHP ^7.4 || ^8.0CI passing

Since Apr 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/RVxLab/hcaptcha)[ Packagist](https://packagist.org/packages/rvxlab/hcaptcha)[ RSS](/packages/rvxlab-hcaptcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (11)Versions (19)Used By (0)

[![Laravel HCaptcha Banner](./banner.png)](./banner.png)

Laravel HCaptcha
================

[](#laravel-hcaptcha)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6fe4f43b78f9a3a7bda549c3b037c0e101507b65ad67d9d25acb8076a84ab4de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7276786c61622f68636170746368612e7376673f6c6162656c3d5061636b6167697374267374796c653d666c61742d737175617265)](https://packagist.org/packages/rvxlab/hcaptcha)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c51522ec68074a85e3cfca364db3b4f6bade48ffd5eec25f46682060bd2eb1f2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7276786c61622f68636170746368612f72756e2d74657374732e796d6c3f6c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://github.com/RVxLab/hcaptcha/actions/workflows/run-tests.yml)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/624294ba6cd137e230515585c3d2ff7fe185b779f97918f4f237d82bb076ac76/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7276786c61622f68636170746368612f7068702d63732d66697865722e796d6c3f6c6162656c3d4c696e74267374796c653d666c61742d737175617265)](https://github.com/RVxLab/hcaptcha/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/2f34fd6c0186a808ad0126457ad43651468930087700fe29131f7c2e247500a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7276786c61622f68636170746368612e7376673f6c6162656c3d446f776e6c6f616473267374796c653d666c61742d737175617265)](https://packagist.org/packages/rvxlab/hcaptcha)

Looking for a maintainer
========================

[](#looking-for-a-maintainer)

I don't have the intention to maintain this package any longer. Captchas only punish the end user and are easily bypassed by bots.

If someone wants to take over, feel free to open a discussion and tag me in it.

---

A package to easily include [HCaptcha](https://hcaptcha.com) in Laravel.

This project is originally based on [laravel-reCAPTCHA](https://github.com/Dylanchouxd/laravel-reCAPTCHA) and forked from [Scyllaly](https://github.com/scyllaly), who seemingly abandoned the project.

This fork is a near-drop-in replacement for Scyllaly's package, maintaining the same namespace for 4.x and 5.x versions.

Requirements
------------

[](#requirements)

Laravel versionMinimum PHP version8.x7.49.x8.010.x8.111.x8.2Need support for Laravel 7 or before? Check the [4.x branch](https://github.com/RVxLab/hcaptcha/tree/4.x).

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

[](#installation)

Install the package with Composer:

```
composer require rvxlab/hcaptcha
```

Publish the config file:

```
php artisan vendor:publish --tag="hcaptcha-config"
```

Optionally publish the translations:

```
php artisan vendor:publish --tag="hcaptcha-lang"
```

Optionally publish the views:

```
php artisan vendor:publish --tag="hcaptcha-views"
```

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

[](#configuration)

Add `HCAPTCHA_SECRET` and `HCAPTCHA_SITEKEY` in **.env** file :

```
HCAPTCHA_SECRET=secret-key
HCAPTCHA_SITEKEY=site-key

```

You can obtain them from [your HCaptcha dashboard](https://dashboard.hcaptcha.com).

Usage
-----

[](#usage)

### Prepare the script

[](#prepare-the-script)

First you need to initialize the script:

```
{!! HCaptcha::renderJs() !!}
// Or

```

You can optionally set the locale and the custom callback function:

```
{!! HCaptcha::renderJs('nl', true, 'myCallbackFunction') !!}
// Or

```

You can also use the app locale if you have a multilingual application:

```

```

### Render the widget

[](#render-the-widget)

This package provides support for the regular widget, as well as the invisible captcha.

Initialize the regular widget:

```
{!! HCaptcha::display() !!}
// Or

```

Any attributes can be passed as an array to the `display` method or as properties on the Blade component:

```
{!! HCaptcha::display([ 'class' => 'my-widget', 'data-test' => 'Test' ]) !!}
// Or

```

### Invisible widget

[](#invisible-widget)

If you rather want forms to have an invisible widget:

```

    {!! HCaptcha::displaySubmit('register-form', 'Submit', [ 'class' => 'btn' ]) !!}
    // Or

        Submit

    @csrf

```

If you have a custom callback defined for your forms you can define a `data-callback` attribute:

```
{!! HCaptcha::displaySubmit('register-form', 'Submit', [ 'class' => 'btn', 'data-callback' => 'userDefinedCallback ]) !!}
// Or

    Submit

```

Validation
----------

[](#validation)

Add `'h-captcha-response' => 'required|HCaptcha'` to the rules array:

```
class RegisterRequest extends \Illuminate\Foundation\Http\FormRequest
{
    public function rules(): array
    {
        return [
            'email' => 'required|email|exists:users,email',
            'password' => 'required',
            'h-captcha-response' => 'required|HCaptcha',
        ];
    }
}
```

Testing
-------

[](#testing)

You can mock the HCaptcha validation by calling the `shouldReceive` method on the `HCaptcha` facade:

```
HCaptcha::shouldReceive('verifyResponse')->once()->andReturnTrue();

HCaptcha::shouldReceive('display')->andReturn('');
```

Or when testing a JSON call:

```
HCaptcha::shouldReceive('verifyResponse')->once()->andReturnTrue();

$response = $this->json('POST', '/register', [
    'h-captcha-response' => '1',
    'email' => 'john@example.com',
    'password' => '123456',
]);
```

Upgrading
---------

[](#upgrading)

Check the [Upgrade Guide](./UPGRADING.md) for notes on updating from 4.x to 5.x.

License
-------

[](#license)

This package is licensed under [MIT](./LICENSE).

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance59

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~101 days

Recently: every ~187 days

Total

15

Last Release

805d ago

Major Versions

1.0 → 2.02020-04-13

2.0 → 3.02020-04-13

3.0 → 4.02020-04-21

4.x-dev → 5.0.02022-02-27

PHP version history (2 changes)1.0PHP &gt;=5.5.5

5.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/46111684?v=4)[rvxlab](/maintainers/rvxlab)[@RVxLab](https://github.com/RVxLab)

---

Top Contributors

[![RVxLab](https://avatars.githubusercontent.com/u/46111684?v=4)](https://github.com/RVxLab "RVxLab (48 commits)")[![Scyllaly](https://avatars.githubusercontent.com/u/30641000?v=4)](https://github.com/Scyllaly "Scyllaly (33 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (22 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (16 commits)")[![rubensrocha](https://avatars.githubusercontent.com/u/10297656?v=4)](https://github.com/rubensrocha "rubensrocha (1 commits)")[![Tofandel](https://avatars.githubusercontent.com/u/6115458?v=4)](https://github.com/Tofandel "Tofandel (1 commits)")

---

Tags

captchahcaptchalaravellaravel-packageslaravelcaptchahcaptcha

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/rvxlab-hcaptcha/health.svg)

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

###  Alternatives

[anhskohbo/no-captcha

No CAPTCHA reCAPTCHA For Laravel.

1.8k8.5M33](/packages/anhskohbo-no-captcha)[josiasmontag/laravel-recaptchav3

Recaptcha V3 for Laravel package

2641.6M2](/packages/josiasmontag-laravel-recaptchav3)[scyllaly/hcaptcha

hCaptcha for Laravel

56169.6k1](/packages/scyllaly-hcaptcha)[buzz/laravel-h-captcha

hCaptcha for Laravel

20154.0k1](/packages/buzz-laravel-h-captcha)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

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