{"id":19865818,"url":"https://github.com/thinhbuzz/laravel-h-captcha","last_synced_at":"2025-04-09T16:10:29.752Z","repository":{"id":56463718,"uuid":"257620452","full_name":"thinhbuzz/laravel-h-captcha","owner":"thinhbuzz","description":"hCaptcha for Laravel","archived":false,"fork":false,"pushed_at":"2025-03-04T13:07:23.000Z","size":25,"stargazers_count":19,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T15:43:56.653Z","etag":null,"topics":["hcaptcha","laravel","laravel-hcaptcha"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/buzz/laravel-h-captcha","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/thinhbuzz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"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}},"created_at":"2020-04-21T14:23:02.000Z","updated_at":"2025-03-04T13:06:45.000Z","dependencies_parsed_at":"2024-06-18T21:36:37.377Z","dependency_job_id":"fc03c54a-f9e2-4386-bf31-fb4dc851812e","html_url":"https://github.com/thinhbuzz/laravel-h-captcha","commit_stats":{"total_commits":9,"total_committers":4,"mean_commits":2.25,"dds":0.4444444444444444,"last_synced_commit":"53435b15cf2094306d65584e68d4ed63dee1b9b9"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinhbuzz%2Flaravel-h-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinhbuzz%2Flaravel-h-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinhbuzz%2Flaravel-h-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinhbuzz%2Flaravel-h-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinhbuzz","download_url":"https://codeload.github.com/thinhbuzz/laravel-h-captcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065283,"owners_count":21041871,"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":["hcaptcha","laravel","laravel-hcaptcha"],"created_at":"2024-11-12T15:24:16.465Z","updated_at":"2025-04-09T16:10:29.730Z","avatar_url":"https://github.com/thinhbuzz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [hCaptcha](https://www.hcaptcha.com) for Laravel\n\n## Features\n\n- [x]  Support Laravel 5/6/7/8/9/10/11/12\n\n- [x] Multiple captcha on page\n\n- [x] Reset captcha\n\n- [x] Auto discover service provider\n\n- [x] Custom request method\n\n- [x] Using difference key\n\n- [x] Dynamic options on runtime\n\n## Installation\n\nAdd the following line to the `require` section of `composer.json`:\n\n```json\n{\n    \"require\": {\n        \"buzz/laravel-h-captcha\": \"2.*\"\n    }\n}\n```\n\nOR\n\nRequire this package with composer:\n```\ncomposer require buzz/laravel-h-captcha\n```\n\nUpdate your packages with ```composer update``` or install with ```composer install```.\n\n## Setup\n\n\u003e Has support auto discover for Laravel \u003e=5.5\n\nAdd ServiceProvider to the `providers` array in `config/app.php`.\n\n```\n'Buzz\\LaravelHCaptcha\\CaptchaServiceProvider',\n```\n\n## Publish Config\n\n```\nphp artisan vendor:publish --provider=\"Buzz\\LaravelHCaptcha\\CaptchaServiceProvider\"\n```\n\n### Custom http client\n\nEdit ``http_client`` in the ``config/captcha.php`` config\n\nfile ``config/captcha.php``\n\n```php\n\u003c?php\n/*\n * Secret key and Site key get on https://dashboard.hcaptcha.com/sites\n * */\nreturn [\n    'secret' =\u003e env('CAPTCHA_SECRET', 'default_secret'),\n    'sitekey' =\u003e env('CAPTCHA_SITEKEY', 'default_sitekey'),\n    // \\GuzzleHttp\\Client used is the default client\n    'http_client' =\u003e \\Buzz\\LaravelHCaptcha\\HttpClient::class,\n    'options' =\u003e [\n        'multiple' =\u003e false,\n        'lang' =\u003e app()-\u003egetLocale(),\n    ],\n    'attributes' =\u003e [\n        'theme' =\u003e 'light'\n    ],\n];\n```\n\n## Configuration\n\nAdd `CAPTCHA_SECRET` and `CAPTCHA_SITEKEY` to **.env** file:\n\n```\nCAPTCHA_SECRET=[secret-key]\nCAPTCHA_SITEKEY=[site-key]\n```\n\n## Usage\n\n### View example\n\u003e Get examples in [examples repo](https://github.com/thinhbuzz/laravel-h-captcha-examples/tree/master/resources/views)\n\n\n### Display hCaptcha\n\n```php\n{!! app('captcha')-\u003edisplay($attributes) !!}\n```\n\nOR use Facade: add `'Captcha' =\u003e '\\Buzz\\LaravelHCaptcha\\CaptchaFacade',` to the `aliases` array in `config/app.php` and in template use:\n\n```php\n{!! Captcha::display($attributes) !!}\n```\nOR use Form\n\n```php\n{!! Form::captcha($attributes) !!}\n```\nWith custom language support:\n```php\n{!! app('captcha')-\u003edisplay($attributes = [], $options = ['lang'=\u003e 'vi']) !!}\n```\n\nWith\n\n```php\n// element attributes\n$attributes = [\n    'data-theme' =\u003e 'dark',\n    'data-type' =\u003e 'audio',\n];\n```\n```php\n// package options\n$options = [\n    'data-theme' =\u003e 'dark',\n    'data-type'\t=\u003e 'audio',\n];\n```\n\nMore information on [hCaptcha document](https://docs.hcaptcha.com/)\n\u003e Please help me write readme for this content\n\n### Validation\n\nAdd `'h-captcha-response' =\u003e 'required|captcha'` to rules array.\n\n```php\nuse Validator;\nuse Illuminate\\Support\\Facades\\Input;\n\n$validate = Validator::make(Input::all(), [\n    'h-captcha-response' =\u003e 'required|captcha'\n]);\n```\n\n### Testing\n\nWhen using the Laravel Testing functionality, you will need to mock out the response for the captcha form element.\nFor any form tests involving the captcha, you can then mock the facade behaviour:\n\n```php\n// Prevent validation error on captcha\n        CaptchaFacade::shouldReceive('verify')\n            -\u003eandReturn(true);\n            \n// Provide hidden input for your 'required' validation\n        CaptchaFacade::shouldReceive('display')\n            -\u003eandReturn('\u003cinput type=\"hidden\" name=\"h-captcha-response\" value=\"1\" /\u003e');\n            \n// Add these when testing multiple captchas on a single page\n        CaptchaFacade::shouldReceive('displayJs');\n        CaptchaFacade::shouldReceive('displayMultiple');\n        CaptchaFacade::shouldReceive('multiple');\n```\n\n## Contribute\n\nhttps://github.com/thinhbuzz/laravel-h-captcha/pulls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinhbuzz%2Flaravel-h-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinhbuzz%2Flaravel-h-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinhbuzz%2Flaravel-h-captcha/lists"}