{"id":13715147,"url":"https://github.com/anhskohbo/no-captcha","last_synced_at":"2025-05-12T13:11:18.020Z","repository":{"id":24124420,"uuid":"27513029","full_name":"anhskohbo/no-captcha","owner":"anhskohbo","description":"No CAPTCHA reCAPTCHA For Laravel.","archived":false,"fork":false,"pushed_at":"2025-02-25T18:54:32.000Z","size":78,"stargazers_count":1818,"open_issues_count":53,"forks_count":236,"subscribers_count":48,"default_branch":"master","last_synced_at":"2025-05-12T04:46:59.862Z","etag":null,"topics":["captcha","captcha-recaptcha","laravel","php"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/anhskohbo/no-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/anhskohbo.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":"2014-12-03T23:26:56.000Z","updated_at":"2025-05-07T19:25:12.000Z","dependencies_parsed_at":"2024-06-18T10:46:08.928Z","dependency_job_id":"8125e06d-c9f3-4853-a486-2943dc4a883a","html_url":"https://github.com/anhskohbo/no-captcha","commit_stats":{"total_commits":86,"total_committers":34,"mean_commits":"2.5294117647058822","dds":0.7093023255813953,"last_synced_commit":"6f129419a7f0d0a1ed9849fdaaed34e6d83a03cc"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anhskohbo%2Fno-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anhskohbo%2Fno-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anhskohbo%2Fno-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anhskohbo%2Fno-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anhskohbo","download_url":"https://codeload.github.com/anhskohbo/no-captcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745166,"owners_count":21957317,"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","captcha-recaptcha","laravel","php"],"created_at":"2024-08-03T00:00:54.939Z","updated_at":"2025-05-12T13:11:17.920Z","avatar_url":"https://github.com/anhskohbo.png","language":"PHP","funding_links":[],"categories":["Biblioteki"],"sub_categories":[],"readme":"No CAPTCHA reCAPTCHA\n==========\n\n[![Build Status](https://travis-ci.org/anhskohbo/no-captcha.svg?branch=master\u0026style=flat-square)](https://travis-ci.org/anhskohbo/no-captcha)\n[![Latest Stable Version](https://poser.pugx.org/anhskohbo/no-captcha/v/stable)](https://packagist.org/packages/anhskohbo/no-captcha)\n[![Total Downloads](https://poser.pugx.org/anhskohbo/no-captcha/downloads)](https://packagist.org/packages/anhskohbo/no-captcha)\n[![Latest Unstable Version](https://poser.pugx.org/anhskohbo/no-captcha/v/unstable)](https://packagist.org/packages/anhskohbo/no-captcha)\n[![License](https://poser.pugx.org/anhskohbo/no-captcha/license)](https://packagist.org/packages/anhskohbo/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/anhskohbo/no-captcha/tree/v1) branch.\n\n## Installation\n\n```\ncomposer require anhskohbo/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\nAnhskohbo\\NoCaptcha\\NoCaptchaServiceProvider::class,\n```\n\n2- The class alias to the aliases array :\n\n```php\n'NoCaptcha' =\u003e Anhskohbo\\NoCaptcha\\Facades\\NoCaptcha::class,\n```\n\n3- Publish the config file\n\n```ssh\nphp artisan vendor:publish --provider=\"Anhskohbo\\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 \\Anhskohbo\\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/anhskohbo/no-captcha/pulls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanhskohbo%2Fno-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanhskohbo%2Fno-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanhskohbo%2Fno-captcha/lists"}