{"id":15293794,"url":"https://github.com/s00d/no-captcha","last_synced_at":"2026-02-10T02:06:35.253Z","repository":{"id":62538783,"uuid":"426644931","full_name":"s00d/no-captcha","owner":"s00d","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-25T15:35:23.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-10T18:44:47.079Z","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/s00d.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-10T14:05:35.000Z","updated_at":"2024-07-25T15:30:53.000Z","dependencies_parsed_at":"2024-10-23T14:01:06.082Z","dependency_job_id":null,"html_url":"https://github.com/s00d/no-captcha","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fno-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fno-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fno-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fno-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s00d","download_url":"https://codeload.github.com/s00d/no-captcha/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244307696,"owners_count":20432072,"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-09-30T16:53:20.511Z","updated_at":"2026-02-10T02:06:32.742Z","avatar_url":"https://github.com/s00d.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"No CAPTCHA reCAPTCHA\n==========\n\n[![Build Status](https://travis-ci.org/s00d/no-captcha.svg?branch=master\u0026style=flat-square)](https://travis-ci.org/s00d/no-captcha)\n[![Latest Stable Version](https://poser.pugx.org/s00d/no-captcha/v/stable)](https://packagist.org/packages/s00d/no-captcha)\n[![Total Downloads](https://poser.pugx.org/s00d/no-captcha/downloads)](https://packagist.org/packages/s00d/no-captcha)\n[![Latest Unstable Version](https://poser.pugx.org/s00d/no-captcha/v/unstable)](https://packagist.org/packages/s00d/no-captcha)\n[![License](https://poser.pugx.org/s00d/no-captcha/license)](https://packagist.org/packages/s00d/no-captcha)\n\n![recaptcha_anchor 2x](https://cloud.githubusercontent.com/assets/1529454/5291635/1c426412-7b88-11e4-8d16-46161a081ece.gif)\n\n\u003e For Laravel 4 use [v1](https://github.com/s00d/no-captcha/tree/v1) branch.\n\n## Installation\n\n```\ncomposer require s00d/no-captcha\n```\n\n## Laravel 5 and above\n\n### Setup\n\n**_NOTE_** This package supports the auto-discovery feature of Laravel 5.5 and above, So skip these `Setup` instructions if you're using Laravel 5.5 and above.\n\nIn `app/config/app.php` add the following :\n\n1- The ServiceProvider to the providers array :\n\n```php\ns00d\\NoCaptcha\\NoCaptchaServiceProvider::class,\n```\n\n2- The class alias to the aliases array :\n\n```php\n'NoCaptcha' =\u003e s00d\\NoCaptcha\\Facades\\NoCaptcha::class,\n```\n\n3- Publish the config file\n\n```ssh\nphp artisan vendor:publish --provider=\"s00d\\NoCaptcha\\NoCaptchaServiceProvider\"\n```\n\n### Configuration\n\nAdd `NOCAPTCHA_SECRET` and `NOCAPTCHA_SITEKEY` in **.env** file :\n\n```\nNOCAPTCHA_SECRET=secret-key\nNOCAPTCHA_SITEKEY=site-key\n```\n\n(You can obtain them from [here](https://www.google.com/recaptcha/admin))\n\n### Usage\n\n#### Init js source\n\nWith default options :\n\n```php\n {!! NoCaptcha::renderJs() !!}\n```\n\nWith [language support](https://developers.google.com/recaptcha/docs/language) or [onloadCallback](https://developers.google.com/recaptcha/docs/display#explicit_render) option :\n\n```php\n {!! NoCaptcha::renderJs('fr', true, 'recaptchaCallback') !!}\n```\n\n#### Display reCAPTCHA\n\nDefault widget :\n\n```php\n{!! NoCaptcha::display() !!}\n```\n\nWith [custom attributes](https://developers.google.com/recaptcha/docs/display#render_param) (theme, size, callback ...) :\n\n```php\n{!! NoCaptcha::display(['data-theme' =\u003e 'dark']) !!}\n```\n\nInvisible reCAPTCHA using a [submit button](https://developers.google.com/recaptcha/docs/invisible):\n\n```php\n{!! NoCaptcha::displaySubmit('my-form-id', 'submit now!', ['data-theme' =\u003e 'dark']) !!}\n```\nNotice that the id of the form is required in this method to let the autogenerated \ncallback submit the form on a successful captcha verification.\n\n#### Validation\n\nAdd `'g-recaptcha-response' =\u003e 'required|captcha'` to rules array :\n\n```php\n$validate = Validator::make(Input::all(), [\n\t'g-recaptcha-response' =\u003e 'required|captcha'\n]);\n\n```\n\n##### Custom Validation Message\n\nAdd the following values to the `custom` array in the `validation` language file :\n\n```php\n'custom' =\u003e [\n    'g-recaptcha-response' =\u003e [\n        'required' =\u003e 'Please verify that you are not a robot.',\n        'captcha' =\u003e 'Captcha error! try again later or contact site admin.',\n    ],\n],\n```\n\nThen check for captcha errors in the `Form` :\n\n```php\n@if ($errors-\u003ehas('g-recaptcha-response'))\n    \u003cspan class=\"help-block\"\u003e\n        \u003cstrong\u003e{{ $errors-\u003efirst('g-recaptcha-response') }}\u003c/strong\u003e\n    \u003c/span\u003e\n@endif\n```\n\n### Testing\n\nWhen using the [Laravel Testing functionality](http://laravel.com/docs/5.5/testing), you will need to mock out the response for the captcha form element.\n\nSo for any form tests involving the captcha, you can do this by mocking the facade behavior:\n\n```php\n// prevent validation error on captcha\nNoCaptcha::shouldReceive('verifyResponse')\n    -\u003eonce()\n    -\u003eandReturn(true);\n\n// provide hidden input for your 'required' validation\nNoCaptcha::shouldReceive('display')\n    -\u003ezeroOrMoreTimes()\n    -\u003eandReturn('\u003cinput type=\"hidden\" name=\"g-recaptcha-response\" value=\"1\" /\u003e');\n```\n\nYou can then test the remainder of your form as normal.\n\nWhen using HTTP tests you can add the `g-recaptcha-response` to the request body for the 'required' validation:\n\n```php\n// prevent validation error on captcha\nNoCaptcha::shouldReceive('verifyResponse')\n    -\u003eonce()\n    -\u003eandReturn(true);\n\n// POST request, with request body including g-recaptcha-response\n$response = $this-\u003ejson('POST', '/register', [\n    'g-recaptcha-response' =\u003e '1',\n    'name' =\u003e 'John',\n    'email' =\u003e 'john@example.com',\n    'password' =\u003e '123456',\n    'password_confirmation' =\u003e '123456',\n]);\n```\n\n## Without Laravel\n\nCheckout example below:\n\n```php\n\u003c?php\n\nrequire_once \"vendor/autoload.php\";\n\n$secret  = 'CAPTCHA-SECRET';\n$sitekey = 'CAPTCHA-SITEKEY';\n$captcha = new \\s00d\\NoCaptcha\\NoCaptcha($secret, $sitekey);\n\nif (! empty($_POST)) {\n    var_dump($captcha-\u003everifyResponse($_POST['g-recaptcha-response']));\n    exit();\n}\n\n?\u003e\n\n\u003cform action=\"?\" method=\"POST\"\u003e\n    \u003c?php echo $captcha-\u003edisplay(); ?\u003e\n    \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n\u003c/form\u003e\n\n\u003c?php echo $captcha-\u003erenderJs(); ?\u003e\n```\n\n## Contribute\n\nhttps://github.com/s00d/no-captcha/pulls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Fno-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs00d%2Fno-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Fno-captcha/lists"}