{"id":13563779,"url":"https://github.com/albertcht/invisible-recaptcha","last_synced_at":"2025-05-14T22:08:06.449Z","repository":{"id":44676522,"uuid":"90275934","full_name":"albertcht/invisible-recaptcha","owner":"albertcht","description":"An invisible reCAPTCHA package for Laravel, Lumen, CI or native PHP.","archived":false,"fork":false,"pushed_at":"2024-07-12T09:53:14.000Z","size":140,"stargazers_count":604,"open_issues_count":29,"forks_count":165,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-15T00:43:47.976Z","etag":null,"topics":[],"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/albertcht.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":"2017-05-04T14:56:37.000Z","updated_at":"2025-03-03T14:41:11.000Z","dependencies_parsed_at":"2024-09-24T14:30:39.036Z","dependency_job_id":null,"html_url":"https://github.com/albertcht/invisible-recaptcha","commit_stats":{"total_commits":94,"total_committers":23,"mean_commits":4.086956521739131,"dds":0.3936170212765957,"last_synced_commit":"12a4aec36c32e4c4b97884ff6cae97859eb69098"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertcht%2Finvisible-recaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertcht%2Finvisible-recaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertcht%2Finvisible-recaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertcht%2Finvisible-recaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/albertcht","download_url":"https://codeload.github.com/albertcht/invisible-recaptcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235696,"owners_count":22036963,"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-08-01T13:01:23.214Z","updated_at":"2025-05-14T22:08:01.433Z","avatar_url":"https://github.com/albertcht.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"Invisible reCAPTCHA\n==========\n![php-badge](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg)\n[![packagist-badge](https://img.shields.io/packagist/v/albertcht/invisible-recaptcha.svg)](https://packagist.org/packages/albertcht/invisible-recaptcha)\n[![Total Downloads](https://poser.pugx.org/albertcht/invisible-recaptcha/downloads)](https://packagist.org/packages/albertcht/invisible-recaptcha)\n[![travis-badge](https://api.travis-ci.org/albertcht/invisible-recaptcha.svg?branch=master)](https://travis-ci.org/albertcht/invisible-recaptcha)\n\n![invisible_recaptcha_demo](http://i.imgur.com/1dZ9XKn.png)\n\n## Why Invisible reCAPTCHA?\n\nInvisible reCAPTCHA is an improved version of reCAPTCHA v2(no captcha).\nIn reCAPTCHA v2, users need to click the button: \"I'm not a robot\" to prove they are human. In invisible reCAPTCHA, there will be not embed a captcha box for users to click. It's totally invisible! Only the badge will show on the buttom of the page to hint users that your website is using this technology. (The badge could be hidden, but not suggested.)\n\n## Notice\n\n* The master branch doesn't support multi captchas feature, please use `multi-forms` branch if you need it. (**Most of the time you are misusing recaptcha when you try to put multiple captchas in one page.**)\n\n## Installation\n\n```\ncomposer require albertcht/invisible-recaptcha\n```\n\n## Laravel 5\n\n### Setup\n\nAdd ServiceProvider to the providers array in `app/config/app.php`.\n\n```\nAlbertCht\\InvisibleReCaptcha\\InvisibleReCaptchaServiceProvider::class,\n```\n\n\u003e It also supports package discovery for Laravel 5.5.\n\n### Configuration\nBefore you set your config, remember to choose `invisible reCAPTCHA` while applying for keys.\n![invisible_recaptcha_setting](http://i.imgur.com/zIAlKbY.jpg)\n\nAdd `INVISIBLE_RECAPTCHA_SITEKEY`, `INVISIBLE_RECAPTCHA_SECRETKEY` to **.env** file.\n\n```\n// required\nINVISIBLE_RECAPTCHA_SITEKEY={siteKey}\nINVISIBLE_RECAPTCHA_SECRETKEY={secretKey}\n\n// optional\nINVISIBLE_RECAPTCHA_BADGEHIDE=false\nINVISIBLE_RECAPTCHA_DATABADGE='bottomright'\nINVISIBLE_RECAPTCHA_TIMEOUT=5\nINVISIBLE_RECAPTCHA_DEBUG=false\n```\n\n\u003e There are three different captcha styles you can set: `bottomright`, `bottomleft`, `inline`\n\n\u003e If you set `INVISIBLE_RECAPTCHA_BADGEHIDE` to true, you can hide the badge logo.\n\n\u003e You can see the binding status of those catcha elements on browser console by setting `INVISIBLE_RECAPTCHA_DEBUG` as true.\n\n### Usage\n\nBefore you render the captcha, please keep those notices in mind:\n\n* `render()` or `renderHTML()` function needs to be called within a form element.\n* You have to ensure the `type` attribute of your submit button has to be `submit`.\n* There can only be one submit button in your form.\n\n##### Display reCAPTCHA in Your View\n\n```php\n{!! app('captcha')-\u003erender() !!}\n\n// or you can use this in blade\n@captcha\n```\n\nWith custom language support:\n\n```php\n{!! app('captcha')-\u003erender('en') !!}\n\n// or you can use this in blade\n@captcha('en')\n```\n\n##### Usage with Javascript frameworks like VueJS:\n\nThe `render()` process includes three distinct sections that can be rendered separately incase you're using the package with a framework like VueJS which throws console errors when `\u003cscript\u003e` tags are included in templates.\n\nYou can render the polyfill (do this somewhere like the head of your HTML:)\n\n```php\n{!! app('captcha')-\u003erenderPolyfill() !!}\n// Or with blade directive:\n@captchaPolyfill\n```\n\nYou can render the HTML using this following, this needs to be INSIDE your `\u003cform\u003e` tag:\n\n```php\n{!! app('captcha')-\u003erenderCaptchaHTML() !!}\n// Or with blade directive:\n@captchaHTML\n```\n\nAnd you can render the neccessary `\u003cscript\u003e` tags including the optional language support by using:\n\n```php\n// The argument is optional.\n{!! app('captcha')-\u003erenderFooterJS('en') !!}\n\n// Or with blade directive:\n@captchaScripts\n// blade directive, with language support:\n@captchaScripts('en')\n\n```\n\n##### Validation\n\nAdd `'g-recaptcha-response' =\u003e 'required|captcha'` to rules array.\n\n```php\n$validate = Validator::make(Input::all(), [\n    'g-recaptcha-response' =\u003e 'required|captcha'\n]);\n\n```\n\n## CodeIgniter 3.x\n\nset in application/config/config.php :\n```php\n$config['composer_autoload'] = TRUE;\n```\n\nadd lines in application/config/config.php :\n```php\n$config['recaptcha.sitekey'] = 'sitekey'; \n$config['recaptcha.secret'] = 'secretkey';\n// optional\n$config['recaptcha.options'] = [\n    'hideBadge' =\u003e false,\n    'dataBadge' =\u003e 'bottomright',\n    'timeout' =\u003e 5,\n    'debug' =\u003e false\n];\n```\n\nIn controller, use:\n```php\n$data['captcha'] = new \\AlbertCht\\InvisibleReCaptcha\\InvisibleReCaptcha(\n    $this-\u003econfig-\u003eitem('recaptcha.sitekey'),\n    $this-\u003econfig-\u003eitem('recaptcha.secret'),\n    $this-\u003econfig-\u003eitem('recaptcha.options'),\n);\n```\n\nIn view, in your form:\n```php\n\u003c?php echo $captcha-\u003erender(); ?\u003e\n```\n\nThen back in your controller you can verify it:\n```php\n$captcha-\u003everifyResponse($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);\n```\n\n## Without Laravel or CodeIgniter\n\nCheckout example below:\n\n```php\n\u003c?php\n\nrequire_once \"vendor/autoload.php\";\n\n$siteKey = 'sitekey';\n$secretKey = 'secretkey';\n// optional\n$options = [\n    'hideBadge' =\u003e false,\n    'dataBadge' =\u003e 'bottomright',\n    'timeout' =\u003e 5,\n    'debug' =\u003e false\n];\n$captcha = new \\AlbertCht\\InvisibleReCaptcha\\InvisibleReCaptcha($siteKey, $secretKey, $options);\n\n// you can override single option config like this\n$captcha-\u003esetOption('debug', true);\n\nif (!empty($_POST)) {\n    var_dump($captcha-\u003everifyResponse($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']));\n    exit();\n}\n\n?\u003e\n\n\u003cform action=\"?\" method=\"POST\"\u003e\n    \u003c?php echo $captcha-\u003erender(); ?\u003e\n    \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n\u003c/form\u003e\n```\n\n## Take Control of Submit Function\nUse this function only when you need to take all control after clicking submit button. Recaptcha validation will not be triggered if you return false in this function.\n\n```javascript\n_beforeSubmit = function(e) {\n    console.log('submit button clicked.');\n    // do other things before captcha validation\n    // e represents reference to original form submit event\n    // return true if you want to continue triggering captcha validation, otherwise return false\n    return false;\n}\n```\n\n## Customize Submit Function\nIf you want to customize your submit function, for example: doing something after click the submit button or changing your submit to ajax call, etc.\n\nThe only thing you need to do is to implement `_submitEvent` in javascript\n```javascript\n_submitEvent = function() {\n    console.log('submit button clicked.');\n    // write your logic here\n    // submit your form\n    _submitForm();\n}\n```\nHere's an example to use an ajax submit (using jquery selector)\n```javascript\n_submitEvent = function() {\n    $.ajax({\n        type: \"POST\",\n        url: \"{{route('message.send')}}\",\n         data: {\n            \"name\": $(\"#name\").val(),\n            \"email\": $(\"#email\").val(),\n            \"content\": $(\"#content\").val(),\n            // important! don't forget to send `g-recaptcha-response`\n            \"g-recaptcha-response\": $(\"#g-recaptcha-response\").val()\n        },\n        dataType: \"json\",\n        success: function(data) {\n            // success logic\n        },\n        error: function(data) {\n            // error logic\n        }\n    });\n};\n```\n## Example Repository\nRepo: https://github.com/albertcht/invisible-recaptcha-example\n\nThis repo demonstrates how to use this package with ajax way.\n\n## Showcases\n\n* [Laravel Boilerplate](https://github.com/Labs64/laravel-boilerplate)\n\n## Credits \n\n* anhskohbo (the author of no-captcha package)\n* [Contributors](https://github.com/albertcht/invisible-recaptcha/graphs/contributors)\n\n## Support on Beerpay\nHey dude! Help me out for a couple of :beers:!\n\n[![Beerpay](https://beerpay.io/albertcht/invisible-recaptcha/badge.svg?style=beer-square)](https://beerpay.io/albertcht/invisible-recaptcha)  [![Beerpay](https://beerpay.io/albertcht/invisible-recaptcha/make-wish.svg?style=flat-square)](https://beerpay.io/albertcht/invisible-recaptcha?focus=wish)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertcht%2Finvisible-recaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbertcht%2Finvisible-recaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertcht%2Finvisible-recaptcha/lists"}