{"id":19865819,"url":"https://github.com/thinhbuzz/laravel-google-captcha","last_synced_at":"2025-05-15T01:07:26.731Z","repository":{"id":35917562,"uuid":"40205107","full_name":"thinhbuzz/laravel-google-captcha","owner":"thinhbuzz","description":"Google captcha for Laravel, support multiple captcha on page","archived":false,"fork":false,"pushed_at":"2025-03-04T12:58:16.000Z","size":63,"stargazers_count":206,"open_issues_count":1,"forks_count":32,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-10T06:33:53.543Z","etag":null,"topics":["google-captcha","laravel","laravel-captcha"],"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/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,"zenodo":null}},"created_at":"2015-08-04T19:33:39.000Z","updated_at":"2025-03-10T03:39:14.000Z","dependencies_parsed_at":"2024-06-18T13:45:18.880Z","dependency_job_id":"57793186-7747-4dda-a1e8-ebef475153f8","html_url":"https://github.com/thinhbuzz/laravel-google-captcha","commit_stats":{"total_commits":56,"total_committers":17,"mean_commits":"3.2941176470588234","dds":0.4107142857142857,"last_synced_commit":"bbddd708fd966fb3e351eb7b150c576d011e7d5b"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinhbuzz%2Flaravel-google-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinhbuzz%2Flaravel-google-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinhbuzz%2Flaravel-google-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinhbuzz%2Flaravel-google-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinhbuzz","download_url":"https://codeload.github.com/thinhbuzz/laravel-google-captcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254254041,"owners_count":22039792,"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":["google-captcha","laravel","laravel-captcha"],"created_at":"2024-11-12T15:24:16.471Z","updated_at":"2025-05-15T01:07:21.721Z","avatar_url":"https://github.com/thinhbuzz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google captcha for Laravel\n\u003e Support multiple captcha on page\n\n![Google captcha for Laravel](http://i.imgur.com/aHBOqAS.gif)\n\n\u003e Inspired by [anhskohbo/no-captcha](https://github.com/anhskohbo/no-captcha) and base on [google captcha sdk](https://github.com/google/recaptcha).\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-google-captcha\": \"2.*\"\n    }\n}\n```\n\nOR\n\nRequire this package with composer:\n```\ncomposer require buzz/laravel-google-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\\LaravelGoogleCaptcha\\CaptchaServiceProvider',\n```\n\n## Publish Config\n\n```\nphp artisan vendor:publish --provider=\"Buzz\\LaravelGoogleCaptcha\\CaptchaServiceProvider\"\n```\n\n### Custom ReCaptcha request (minimum version 2.1.7)\n\nEdit ``request_method`` 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://www.google.com/recaptcha\n * */\nreturn [\n    'secret' =\u003e env('CAPTCHA_SECRET', 'default_secret'),\n    'sitekey' =\u003e env('CAPTCHA_SITEKEY', 'default_sitekey'),\n    /**\n     * @var string|null Default ``null``.\n     * Custom with function name (example customRequestCaptcha) or class@method (example \\App\\CustomRequestCaptcha@custom).\n     * Function must be return instance, read more in repo ``https://github.com/thinhbuzz/laravel-google-captcha-examples``\n     */\n    'request_method' =\u003e null,\n    'options' =\u003e [\n        'multiple' =\u003e false,\n        'lang' =\u003e app()-\u003egetLocale(),\n    ],\n    'attributes' =\u003e [\n        'theme' =\u003e 'light'\n    ],\n];\n```\n\nfile ``app/helpers.php``\n\n```php\n\u003c?php\n\nfunction customRequestCaptcha(){\n    return new \\ReCaptcha\\RequestMethod\\Post();\n}\n```\n\nor file ``app/CustomRequestCaptcha.php``\n\n```php\n\u003c?php\n\nnamespace App;\n\nclass CustomRequestCaptcha\n{\n    public function custom()\n    {\n        return new \\ReCaptcha\\RequestMethod\\Post();\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-google-captcha-examples)\n\n\n### Display reCAPTCHA\n\n```php\n{!! app('captcha')-\u003edisplay($attributes) !!}\n```\n\nOR use Facade: add `'Captcha' =\u003e '\\Buzz\\LaravelGoogleCaptcha\\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 [google recaptcha document](https://developers.google.com/recaptcha/docs/display)\n\u003e Please help me write readme for this content\n\n### Validation\n\nAdd `'g-recaptcha-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    'g-recaptcha-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=\"g-recaptcha-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-google-captcha/pulls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinhbuzz%2Flaravel-google-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinhbuzz%2Flaravel-google-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinhbuzz%2Flaravel-google-captcha/lists"}