{"id":14983665,"url":"https://github.com/nietonfir/googlerecaptchabundle","last_synced_at":"2025-04-10T19:03:03.136Z","repository":{"id":25186203,"uuid":"28609549","full_name":"nietonfir/GoogleRecaptchaBundle","owner":"nietonfir","description":null,"archived":false,"fork":false,"pushed_at":"2017-04-16T22:53:36.000Z","size":41,"stargazers_count":10,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T06:41:42.686Z","etag":null,"topics":["captcha","composer","google-recaptcha","php","recaptcha","symfony-bundle","symfony2","symfony3"],"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/nietonfir.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":"2014-12-29T23:01:04.000Z","updated_at":"2022-02-26T22:11:00.000Z","dependencies_parsed_at":"2022-09-05T12:41:01.228Z","dependency_job_id":null,"html_url":"https://github.com/nietonfir/GoogleRecaptchaBundle","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/nietonfir%2FGoogleRecaptchaBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nietonfir%2FGoogleRecaptchaBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nietonfir%2FGoogleRecaptchaBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nietonfir%2FGoogleRecaptchaBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nietonfir","download_url":"https://codeload.github.com/nietonfir/GoogleRecaptchaBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239362413,"owners_count":19626127,"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","composer","google-recaptcha","php","recaptcha","symfony-bundle","symfony2","symfony3"],"created_at":"2024-09-24T14:07:45.081Z","updated_at":"2025-02-17T20:32:25.150Z","avatar_url":"https://github.com/nietonfir.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"GoogleReCaptchaBundle\n=====================\n\n[ReCAPTCHA](https://developers.google.com/recaptcha/) is a free CAPTCHA service that protects websites from spam and abuse.\nThis bundle uses the [GoogleReCaptcha](https://github.com/nietonfir/GoogleReCaptcha) library or validating a users \"No CAPTCHA reCAPTCHA\" response and provides a custom form type, a custom validation constraint as well as a validator to use with the [Symfony Form Component](https://github.com/symfony/Form).\n\n[![Latest Stable Version](https://poser.pugx.org/nietonfir/google-recaptcha-bundle/v/stable.svg)](https://packagist.org/packages/nietonfir/google-recaptcha-bundle) [![Latest Unstable Version](https://poser.pugx.org/nietonfir/google-recaptcha-bundle/v/unstable.svg)](https://packagist.org/packages/nietonfir/google-recaptcha-bundle) [![License](https://poser.pugx.org/nietonfir/google-recaptcha-bundle/license.svg)](https://packagist.org/packages/nietonfir/google-recaptcha-bundle)\n\nInstallation\n------------\n\nThe recommended way to install GoogleReCaptchaBundle is through\n[Composer](http://getcomposer.org).\n\n```bash\n# Install Composer\ncurl -sS https://getcomposer.org/installer | php\n```\n\nNext, run the Composer command to install the latest stable version of GoogleReCaptcha:\n\n```bash\ncomposer require \"nietonfir/google-recaptcha-bundle\"\n```\n\nOr add GoogleReCaptchaBundle in your `composer.json`\n\n```js\n\"require\": {\n    \"nietonfir/google-recaptcha-bundle\": \"v0.0.3\"\n}\n```\n\nand tell Composer to install the library:\n\n``` bash\ncomposer update \"nietonfir/google-recaptcha-bundle\"\n```\n\nAfter installing, don't forget to enable the bundle:\n\n```php\n\u003c?php\n// app/AppKernel.php\n\npublic function registerBundles()\n{\n    $bundles = array(\n        // ...\n        new Nietonfir\\Google\\ReCaptchaBundle\\NietonfirGoogleReCaptchaBundle(),\n    );\n}\n```\n\nConfiguration\n-------------\n\nAdd the following simple configuration to your `config.yml`.\n```yaml\nnietonfir_google_recaptcha:\n    sitekey: \u003cyour_site_key_here\u003e\n    secret: \u003cand_your_secret_here\u003e\n    validation: '\u003cyour_form_name\u003e'\n```\n\n### Multiple forms\n\nReCaptcha can also be added to different forms (while not on the same page!):\n```yaml\nnietonfir_google_recaptcha:\n    validation: [ '\u003cyour_form_name_A\u003e', '\u003cyour_form_name_B\u003e' ]\n```\n\n### Custom form field name\n\nThe form field name containing the recaptcha response, which defaults to `recaptcha`, can be customized as well:\n```yaml\nnietonfir_google_recaptcha:\n    validation:\n        forms:\n            - {form_name: '\u003cyour_form_name_A\u003e', field_name: 'recaptcha'}\n            - {form_name: '\u003cyour_form_name_B\u003e', field_name: 'recaptcha'}\n```\n\nAdditionally you have to add the corresponding form field themes depending on\nyour used templating engine in `config.yml`.\n\n```yaml\n# Twig\ntwig:\n    debug:            \"%kernel.debug%\"\n    strict_variables: \"%kernel.debug%\"\n    form_themes:\n        - 'NietonfirGoogleReCaptchaBundle:Form:fields.html.twig'\n\n# PHP\nframework:\n    templating:\n        form:\n            resources:\n                - 'NietonfirGoogleReCaptchaBundle:Form'\n```\n\nUsage\n-----\n\nUsing the Bundle is dead simple:\n\n1. Create your form type as usual\n2. Add a field using the `recaptcha` field type\n    \n    ```php\n    use Nietonfir\\Google\\ReCaptchaBundle\\Form\\Type\\ReCaptchaType;\n    \n    $builder-\u003eadd('recaptcha', ReCaptchaType::class);\n    ```\n    \n3. Add the necessary javascript library to your template\n    ```html\n    \u003cscript src='https://www.google.com/recaptcha/api.js' async defer\u003e\u003c/script\u003e\n    ```\n\n4. Make your controller implement `ReCaptchaValidationInterface`\n    \n    ```php\n    use Nietonfir\\Google\\ReCaptchaBundle\\Controller\\ReCaptchaValidationInterface;\n\n    class DefaultController extends Controller implements ReCaptchaValidationInterface\n    ```\n    \nNow when `form-\u003eisValid()` is called, the submitted reCAPTCHA response is validated against the Google API.\nBe advised that both the form and the field name used have to be set in `config.yml`.\n\nTODOs\n-----\n* [x] Add some `info()` to the form \u0026 field name config values in `Configuration.php`\n* [x] Translate the error messages returned from the Google API to something more meaningful\n* [ ] Update documentation\n* [ ] Add some more examples\n* [x] Add missing unit tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnietonfir%2Fgooglerecaptchabundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnietonfir%2Fgooglerecaptchabundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnietonfir%2Fgooglerecaptchabundle/lists"}