{"id":14974916,"url":"https://github.com/hendurhance/laracaptcha","last_synced_at":"2025-10-27T10:31:42.022Z","repository":{"id":180755290,"uuid":"664047832","full_name":"hendurhance/laracaptcha","owner":"hendurhance","description":"A Laravel package to seamlessly use hCapthca or reCaptcha v2 or v3 on your forms or RESTful APIs","archived":false,"fork":false,"pushed_at":"2023-12-04T21:33:02.000Z","size":75,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-28T19:41:25.739Z","etag":null,"topics":["captcha","data-validation","form-validation","google-recaptcha","google-recaptcha-v2","google-recaptcha-v3","hcaptcha","hcaptcha-api","laravel","laravel-captcha","laravel-package","laravel10","laravel8","laravel9","php","php8","recaptcha","recaptcha-api","recaptcha-v2","recaptcha-v3"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hendurhance.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["hendurhance"],"custom":["https://www.buymeacoffee.com/hendurhance"]}},"created_at":"2023-07-08T19:22:21.000Z","updated_at":"2023-08-27T03:17:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"22f5fda6-6b35-4dc8-abe3-ed85591f2dfc","html_url":"https://github.com/hendurhance/laracaptcha","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"e6bdce7db168b243c182a128f17c1a1bc48295fe"},"previous_names":["hendurhance/laracaptcha"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hendurhance%2Flaracaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hendurhance%2Flaracaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hendurhance%2Flaracaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hendurhance%2Flaracaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hendurhance","download_url":"https://codeload.github.com/hendurhance/laracaptcha/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219861468,"owners_count":16555994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["captcha","data-validation","form-validation","google-recaptcha","google-recaptcha-v2","google-recaptcha-v3","hcaptcha","hcaptcha-api","laravel","laravel-captcha","laravel-package","laravel10","laravel8","laravel9","php","php8","recaptcha","recaptcha-api","recaptcha-v2","recaptcha-v3"],"created_at":"2024-09-24T13:51:15.752Z","updated_at":"2025-10-27T10:31:42.017Z","avatar_url":"https://github.com/hendurhance.png","language":"PHP","funding_links":["https://github.com/sponsors/hendurhance","https://www.buymeacoffee.com/hendurhance"],"categories":[],"sub_categories":[],"readme":"# LaraCaptcha\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/martian/laracaptcha.svg?style=flat-square)](https://packagist.org/packages/martian/laracaptcha)\n[![Total Downloads](https://img.shields.io/packagist/dt/martian/laracaptcha.svg?style=flat-square)](https://packagist.org/packages/martian/laracaptcha)\n![GitHub Actions](https://github.com/hendurhance/laracaptcha/actions/workflows/main.yml/badge.svg)\n\nA Laravel package to seamlessly integrate Google [reCAPTCHA](https://developers.google.com/recaptcha/intro) v3, v2 or [hCAPTCHA](https://www.hcaptcha.com/) into your application forms or Restful API.\n\n\u003c!-- image flex  --\u003e\n\u003cdiv style=\"display: flex; justify-content: space-between;\"\u003e\n  \u003cfigure style=\"text-align: center; flex: 1;\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/59781900/163660320-8209d05d-c7ed-40f3-831b-3dde16904014.png\" alt=\"Image 1\" width=\"200px\"/\u003e\n    \u003cfigcaption style=\"text-align: center;\"\u003ehCaptcha\u003c/figcaption\u003e\n  \u003c/figure\u003e\n  \u003cfigure style=\"text-align: center; flex: 1;\"\u003e\n    \u003cimg src=\"https://cloud.githubusercontent.com/assets/1529454/5291635/1c426412-7b88-11e4-8d16-46161a081ece.gif\" alt=\"Image 2\" width=\"200px\"/\u003e\n    \u003cfigcaption style=\"text-align: center;\"\u003ereCaptcha\u003c/figcaption\u003e\n  \u003c/figure\u003e\n\u003c/div\u003e\n\n## Supported Captcha Services\n| Service | Version | Type | Supported |\n| --- | --- | --- | --- |\n| [Google reCAPTCHA](https://developers.google.com/recaptcha/docs/v3) | v3 | - | ✅ Yes |\n| [Google reCAPTCHA](https://developers.google.com/recaptcha/docs/display) | v2 | Checkbox | ✅ Yes |\n| [Google reCAPTCHA](https://developers.google.com/recaptcha/docs/invisible) | v2 | Invisible | ✅ Yes |\n| [hCAPTCHA](https://docs.hcaptcha.com/) | - | Checkbox | ✅ Yes |\n| [hCAPTCHA](https://docs.hcaptcha.com/invisible) | - | Invisible | ✅ Yes |\n\n\n## Installation\n\u003e **Note:** This package requires PHP 8.2 or higher and Laravel 11.0 or higher.\n\nYou can install the package via composer:\n\n```bash\ncomposer require martian/laracaptcha\n```\n\n## Register Service Provider\nAdd the following to the `providers` array in `config/app.php`:\n\n```php\nMartian\\LaraCaptcha\\Providers\\LaraCaptchaServiceProvider::class,\n```\n\n## Publish Configuration File\nPublish the configuration file using the following command:\n\n```bash\nphp artisan vendor:publish --provider=\"Martian\\LaraCaptcha\\Providers\\LaraCaptchaServiceProvider\"\n```\n\n\n## Configuration\nThe configuration file is located at `config/laracaptcha.php`. The following options are available:\n\n### reCAPTCHA v2 Configuration\n- In order to use reCAPTCHA you need to [register your site](https://www.google.com/recaptcha/admin/create) for an API key pair. To use reCaptcha v2 Checkbox, select **Challenge (v2)** **\u003e** **I'm not a robot Checkbox**. To use the invisible reCAPTCHA, select **Challenge (v2)** **\u003e** **Invisible reCAPTCHA badge**. The API key pair consists of a site key and secret key. Set the `default` option to `recaptcha` in `config/laracaptcha.php`:\n\n    ```php\n    'default' =\u003e 'recaptcha',\n    ```\n- Change the `version` option to `v2` to use reCAPTCHA v2:\n    ```php\n    'drivers' =\u003e [\n        'recaptcha' =\u003e [\n            ...\n            'version' =\u003e 'v2',\n            ...\n        ],\n    ],\n    ```\n- Add `RECAPTCHA_SITE_KEY` and `RECAPTCHA_SECRET_KEY` to your `.env` file:\n\n    ```env\n    RECAPTCHA_SITE_KEY=your-site-key\n    RECAPTCHA_SECRET_KEY=your-secret-key\n    ```\n\n### reCAPTCHA v3 Configuration\n- In order to use reCAPTCHA you need to [register your site](https://www.google.com/recaptcha/admin/create) for an API key pair. To use reCaptcha v3, select **reCAPTCHA v3**. The API key pair consists of a site key and secret key. Set the `default` option to `recaptcha` in `config/laracaptcha.php`:\n\n    ```php\n    'default' =\u003e 'recaptcha',\n    ```\n- Change the `version` option to `v3` to use reCAPTCHA v3:\n    ```php\n    'drivers' =\u003e [\n        'recaptcha' =\u003e [\n            ...\n            'version' =\u003e 'v3',\n            ...\n        ],\n    ],\n    ```\n- Add `RECAPTCHA_SITE_KEY`, `RECAPTCHA_SECRET_KEY` and `RECAPTCHA_SITE_URL` to your `.env` file:\n\n    ```env\n    RECAPTCHA_SITE_KEY=your-site-key\n    RECAPTCHA_SECRET_KEY=your-secret-key\n    RECAPTCHA_SITE_URL=${APP_URL}\n    ```\n\n### hCAPTCHA Configuration\n- In order to use hCAPTCHA you need to [register your site](https://dashboard.hcaptcha.com/signup) for an API key pair. The API key pair consists of a site key and secret key. Set the `default` option to `hcaptcha` in `config/laracaptcha.php`:\n\n    ```php\n    'default' =\u003e 'hcaptcha',\n    ```\n- Add `HCAPTCHA_SITE_KEY` and `HCAPTCHA_SECRET_KEY` to your `.env` file:\n\n    ```env\n    HCAPTCHA_SITE_KEY=10000000-ffff-ffff-ffff-000000000001\n    HCAPTCHA_SECRET_KEY=0x0000000000000000000000000000000000000000\n    ```\n*These are the test keys we use by default. You should not use them in production!*\n## Usage\nTo display captcha in your form, follow the steps below according to the captcha configuration you are using.\n\n### reCAPTCHA v2 Checkbox \u0026 Invisible\n#### Initializing JavaScript\nAdd the following to the `\u003chead\u003e` section of your page:\n```php\n{!! LaraCaptcha::script() !!}\n```\nWith other options in [Google reCaptcha v2 Checkbox dox](https://developers.google.com/recaptcha/docs/display#config)\n```php\n{!! LaraCaptcha::script('yourCallbackFunction', 'explicit', 'en') !!}\n```\n*Note: The first parameter is the callback function name, the second is the rendering mode (explicit or onload), and the third is the language code from [doc](https://developers.google.com/recaptcha/docs/language)*\n\n#### Displaying Captcha Widget - Checkbox\nAdd the following to your form:\n```php\n{!! LaraCaptcha::display() !!}\n```\nWith other options in [Google reCaptcha v2 Checkbox dox](https://developers.google.com/recaptcha/docs/display#render_param)\n```php\n{!! LaraCaptcha::display(['data-theme' =\u003e 'dark']) !!}\n```\n*Note: The parameter is an array of attributes for the widget*\n\n#### Displaying Captcha Widget - Invisible\nAdd the following to your form:\n```php\n{!! LaraCaptcha::displayInvisibleButton('formIdentifier', 'Submit Button',['data-size' =\u003e 'invisible']) !!}\n```\n*Note: The first parameter is the form identifier, the second is the button label (Submit Button), and the third is an array of attributes for the widget, see [doc](https://developers.google.com/recaptcha/docs/invisible#render_param). Add the **formIdentifier** value as the id in the form element* \n#### Validating Captcha\nAdd the following to your validation rules:\n```php\n'g-recaptcha-response' =\u003e 'recaptcha',\n```\nYou can also use the rule in the Validator facade:\n```php\n$validator = Validator::make($request-\u003eall(), [\n    'g-recaptcha-response' =\u003e 'recaptcha',\n]);\n```\n#### Add Custom Validation Message\nAdd the following to your validation messages:\n```php\n'g-recaptcha-response.recaptcha' =\u003e 'Captcha verification failed.',\n```\nOr you can change the default message in `config/laracaptcha.php`:\n```php\n'error_message' =\u003e 'Captcha verification failed.',\n```\n### reCAPTCHA v3\n#### Initializing JavaScript\nAdd the following to the `\u003chead\u003e` section of your page:\n```php\n{!! LaraCaptcha::script() !!}\n```\nWith other options in [Google reCaptcha v3 dox](https://developers.google.com/recaptcha/docs/v3#config)\n```php\n{!! LaraCaptcha::script('yourCallbackFunction', 'explicit', 'en') !!}\n```\n#### Displaying Captcha Widget\nAdd the following to your form:\n```php\n{!! LaraCaptcha::display() !!}\n```\nWith other options in [Google reCaptcha v3 dox](https://developers.google.com/recaptcha/docs/v3#render_param)\n```php\n{!! LaraCaptcha::display(['action' =\u003e 'homepage', 'custom_validation' =\u003e 'yourCustomFunction', 'recaptcha_input_identifier' =\u003e 'yourReCaptchaInputId']) !!}\n```\n*Note: The parameter is an array of attributes for the widget, see [doc](https://developers.google.com/recaptcha/docs/v3#interpreting_the_score) for actions type*\n\n### hCAPTCHA v2 Checkbox \u0026 Invisible\n#### Initializing JavaScript\nAdd the following to the `\u003chead\u003e` section of your page:\n```php\n{!! LaraCaptcha::script() !!}\n```\nWith other options in [hCAPTCHA dox](https://docs.hcaptcha.com/configuration)\n```php\n{!! LaraCaptcha::script('yourCallbackFunction', 'onload', 'en', 'on') !!}\n```\n*Note: The first parameter is the callback function name, the second is the rendering mode (onload or explicit), the third is the language code from [doc](https://docs.hcaptcha.com/languages), and the fourth is the recaptchacompat option*\n\n#### Displaying Captcha Widget - Checkbox\nAdd the following to your form:\n```php\n{!! LaraCaptcha::display() !!}\n```\nWith other options in [hCAPTCHA dox](https://docs.hcaptcha.com/configuration/#hcaptcha-container-configuration)\n```php\n{!! LaraCaptcha::display(['data-theme' =\u003e 'dark']) !!}\n```\n*Note: The parameter is an array of attributes for the widget*\n\n#### Displaying Captcha Widget - Invisible\nAdd the following to your form, see documentation for [invisible hcaptcha](https://docs.hcaptcha.com/invisible):\n```php\n{!! LaraCaptcha::displayInvisibleButton('formIdentifier', 'Submit Button',['data-size' =\u003e 'invisible']) !!}\n```\n*Note: The first parameter is the form identifier, the second is the button label (Submit Button), and the third is an array of attributes for the widget, see [doc](https://docs.hcaptcha.com/configuration/#hcaptcha-container-configuration)*\n\n#### Validating Captcha\nAdd the following to your validation rules:\n```php\n'h-captcha-response' =\u003e 'hcaptcha',\n```\nYou can also use the rule in the Validator facade:\n```php\n$validator = Validator::make($request-\u003eall(), [\n    'h-captcha-response' =\u003e 'hcaptcha',\n]);\n```\n#### Add Custom Validation Message\nAdd the following to your validation messages:\n```php\n'h-captcha-response.hcaptcha' =\u003e 'Captcha verification failed.',\n```\nOr you can change the default message in `config/laracaptcha.php`:\n```php\n'error_message' =\u003e 'Captcha verification failed.',\n```\n\nFor other configuration go through the `config/laracaptcha.php` file.\n### Testing\n\n```bash\n./vendor/bin/phpunit\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email hendurhance.dev@gmail.com instead of using the issue tracker.\n\n## Credits\n\n-   [Josiah Endurance](https://github.com/hendurhance)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhendurhance%2Flaracaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhendurhance%2Flaracaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhendurhance%2Flaracaptcha/lists"}