{"id":15753592,"url":"https://github.com/mcaskill/charcoal-recaptcha","last_synced_at":"2025-03-31T07:42:15.474Z","repository":{"id":62526038,"uuid":"61746137","full_name":"mcaskill/charcoal-recaptcha","owner":"mcaskill","description":"Google reCAPTCHA for Charcoal.","archived":false,"fork":false,"pushed_at":"2021-07-21T19:35:56.000Z","size":57,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T00:48:00.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mcaskill.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-22T19:31:57.000Z","updated_at":"2023-03-08T04:47:14.000Z","dependencies_parsed_at":"2022-11-02T15:45:39.009Z","dependency_job_id":null,"html_url":"https://github.com/mcaskill/charcoal-recaptcha","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcaskill%2Fcharcoal-recaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcaskill%2Fcharcoal-recaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcaskill%2Fcharcoal-recaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcaskill%2Fcharcoal-recaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcaskill","download_url":"https://codeload.github.com/mcaskill/charcoal-recaptcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246436052,"owners_count":20776960,"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":[],"created_at":"2024-10-04T07:41:21.912Z","updated_at":"2025-03-31T07:42:15.453Z","avatar_url":"https://github.com/mcaskill.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google reCAPTCHA for Charcoal\n\n[![License][badge-license]][charcoal/recaptcha]\n[![Latest Stable Version][badge-version]][charcoal/recaptcha]\n[![Code Quality][badge-scrutinizer]][dev-scrutinizer]\n[![Coverage Status][badge-coveralls]][dev-coveralls]\n[![Build Status][badge-travis]][dev-travis]\n\n![Google reCAPTCHA for Charcoal](http://i.imgur.com/aHBOqAS.gif)\n\nA [Charcoal][charcoal/app] service provider for the [Google reCAPTCHA client Library][google/recaptcha].\n\nThis package can be used as a PSR-7 middleware or as an object in your service layer.\n\n\n\n## Installation\n\n```shell\ncomposer require mcaskill/charcoal-recaptcha\n```\n\nSee [`composer.json`](composer.json) for depenencides.\n\n\n\n## What's inside?\n\n-   **`Charcoal\\ReCaptcha\\CaptchaServiceProvider`**: \n    Pimple service provider.\n-   **`Charcoal\\ReCaptcha\\CaptchaConfig`**: \n    Configuring the CAPTCHA service.\n-   **`Charcoal\\ReCaptcha\\CaptchaAwareTrait`**: \n    Convenient trait for interfacing with the CAPTCHA service.\n-   **`Charcoal\\ReCaptcha\\Captcha`**: \n    Service that handles the reCAPTCHA client.\n-   **`Charcoal\\ReCaptcha\\LocalizedCaptcha`**: \n    [Translator-aware][charcoal/translator] variant of the service.\n\n\n\n## Usage\n\n```php\nuse Charcoal\\ReCaptcha\\Captcha;\n\n$captcha = new Captcha([\n    'config' =\u003e [\n        'public_key'  =\u003e '…',\n        'private_key' =\u003e '…',\n    ]\n]);\n\n// As middleware\n$app-\u003epost('/signup', '…')-\u003eadd($captcha);\n\n// As standalone, with direct user input\n$captcha-\u003everify($input, $ip);\n\n// With a PSR-7 request\n$captcha-\u003everifyRequest($request);\n\n// Display the widget in your views\necho $captcha-\u003edisplay(\n    [\n        'data-theme' =\u003e 'dark',\n        'data-type' =\u003e  'audio',\n    ],\n    [\n        'hl' =\u003e 'fr'\n    ]\n);\n```\n\nBy default, the `Captcha` adapter will defer the instantiation of [`ReCaptcha`][class-recaptcha] until the first verification request.\n\n\n\n### Custom ReCaptcha Class\n\nThe `ReCaptcha` class be swapped using the `client_class` option.\n\n```php\nuse Charcoal\\ReCaptcha\\Captcha;\nuse MyApp\\ MyCustomReCaptcha;\n\n$captcha = new Captcha([\n    'config' =\u003e [\n        'public_key'  =\u003e '…',\n        'private_key' =\u003e '…',\n    ],\n    'client_class' =\u003e  MyCustomReCaptcha::class\n]);\n```\n\n\n\n### Custom ReCaptcha Instance\n\nAn instance of the `ReCaptcha` class can be assigned using the `client` option.\n\n```php\nuse Charcoal\\ReCaptcha\\Captcha;\nuse ReCaptcha\\ReCaptcha;\nuse ReCaptcha\\RequestMethod\\CurlPost;\n\n$client = new ReCaptcha('…', new CurlPost());\n\n$captcha = new Captcha([\n    'config' =\u003e [\n        'public_key'  =\u003e '…',\n        'private_key' =\u003e '…',\n    ],\n    'client' =\u003e $client\n]);\n```\n\n\n\n## Service Provider\n\nIf [`CaptchaServiceProvider`](src/CaptchaServiceProvider.php) is used, the following are provided.\n\n\n\n### Parameters\n\n-   **charcoal/captcha/config**: An instance of [`CaptchaConfig`](src/CaptchaConfig.php).\n\n\n\n### Services\n\n-   **charcoal/captcha**: An instance of [`Captcha`](src/CaptchaConfig.php).\n\n\n\n### Registering\n\nVia Charcoal configuration file:\n\n```json\n{\n    \"apis\": {\n        \"google\": {\n            \"recaptcha\": {\n                \"public_key\": \"…\",\n                \"private_key\": \"…\"\n            }\n        },\n    },\n    \"service_providers\": {\n        \"charcoal/re-captcha/captcha\": {}\n    }\n}\n```\n\nVia PHP:\n\n```php\n$container-\u003eregister(new Charcoal\\ReCaptcha\\CaptchaServiceProvider(), [\n    'charcoal/captcha/config' =\u003e [\n        'public_key'  =\u003e '…',\n        'private_key' =\u003e '…'\n    ]\n]);\n```\n\n\n\n## Acknowledgements\n\nThis package is inspired by:\n\n- [`geggleto/psr7-recaptcha`](https://github.com/geggleto/psr7-recaptcha)\n- [`anhskohbo/no-captcha`](https://github.com/anhskohbo/no-captcha)\n- [`buzz/laravel-google-captcha`](https://github.com/thinhbuzz/laravel-google-captcha)\n\n\n\n## License\n\n-   Charcoal reCAPTCHA component is licensed under the MIT license. See [LICENSE](LICENSE) for details.\n-   Charcoal framework is licensed under the MIT license. See [LICENSE][license-charcoal] for details.\n-   Google reCAPTCHA PHP client library is licensed under the BSD License. See the [LICENSE][license-recaptcha] file for details.\n\n\n\n[dev-scrutinizer]:     https://scrutinizer-ci.com/g/mcaskill/charcoal-recaptcha/\n[dev-coveralls]:       https://coveralls.io/r/mcaskill/charcoal-recaptcha\n[dev-travis]:          https://travis-ci.org/mcaskill/charcoal-recaptcha\n\n[badge-license]:       https://img.shields.io/packagist/l/mcaskill/charcoal-recaptcha.svg?style=flat-square\n[badge-version]:       https://img.shields.io/packagist/v/mcaskill/charcoal-recaptcha.svg?style=flat-square\n[badge-scrutinizer]:   https://img.shields.io/scrutinizer/g/mcaskill/charcoal-recaptcha.svg?style=flat-square\n[badge-coveralls]:     https://img.shields.io/coveralls/mcaskill/charcoal-recaptcha.svg?style=flat-square\n[badge-travis]:        https://img.shields.io/travis/mcaskill/charcoal-recaptcha.svg?style=flat-square\n\n[charcoal/recaptcha]:  https://packagist.org/packages/mcaskill/charcoal-recaptcha\n[charcoal/app]:        https://packagist.org/packages/locomotivemtl/charcoal-app\n[charcoal/translator]: https://packagist.org/packages/locomotivemtl/charcoal-translator\n\n[pimple]:              https://packagist.org/packages/pimple/pimple\n[google/recaptcha]:    https://packagist.org/packages/google/recaptcha\n[class-recaptcha]:     https://github.com/google/recaptcha/blob/1.1.3/src/ReCaptcha/ReCaptcha.php\n\n[license-charcoal]:    https://github.com/locomotivemtl/charcoal-app/blob/master/LICENSE\n[license-recaptcha]:   https://github.com/google/recaptcha/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcaskill%2Fcharcoal-recaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcaskill%2Fcharcoal-recaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcaskill%2Fcharcoal-recaptcha/lists"}