{"id":13395995,"url":"https://github.com/mewebstudio/captcha","last_synced_at":"2025-05-14T22:05:22.420Z","repository":{"id":7680149,"uuid":"9043091","full_name":"mewebstudio/captcha","owner":"mewebstudio","description":"Captcha for Laravel 5+","archived":false,"fork":false,"pushed_at":"2025-04-16T15:40:31.000Z","size":1273,"stargazers_count":2517,"open_issues_count":132,"forks_count":464,"subscribers_count":58,"default_branch":"master","last_synced_at":"2025-05-14T22:03:19.432Z","etag":null,"topics":["captcha","laravel","php","security"],"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/mewebstudio.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,"zenodo":null}},"created_at":"2013-03-27T00:01:06.000Z","updated_at":"2025-05-14T21:48:17.000Z","dependencies_parsed_at":"2023-02-16T12:01:31.547Z","dependency_job_id":"2911e60d-e0c6-49ce-8088-5754f536306d","html_url":"https://github.com/mewebstudio/captcha","commit_stats":{"total_commits":194,"total_committers":51,"mean_commits":3.803921568627451,"dds":0.6649484536082475,"last_synced_commit":"8c439263d0ba42e6c05e4d1f3bee0a2b97e675d5"},"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mewebstudio%2Fcaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mewebstudio%2Fcaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mewebstudio%2Fcaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mewebstudio%2Fcaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mewebstudio","download_url":"https://codeload.github.com/mewebstudio/captcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235686,"owners_count":22036962,"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","laravel","php","security"],"created_at":"2024-07-30T18:00:37.296Z","updated_at":"2025-05-14T22:05:22.365Z","avatar_url":"https://github.com/mewebstudio.png","language":"PHP","readme":"# Captcha for Laravel 10/11/12\n\n[![Build Status](https://travis-ci.org/mewebstudio/captcha.svg?branch=master)](https://travis-ci.org/mewebstudio/captcha) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mewebstudio/captcha/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mewebstudio/captcha/?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/mews/captcha/v/stable.svg)](https://packagist.org/packages/mews/captcha)\n[![Latest Unstable Version](https://poser.pugx.org/mews/captcha/v/unstable.svg)](https://packagist.org/packages/mews/captcha)\n[![License](https://poser.pugx.org/mews/captcha/license.svg)](https://packagist.org/packages/mews/captcha)\n[![Total Downloads](https://poser.pugx.org/mews/captcha/downloads.svg)](https://packagist.org/packages/mews/captcha)\n\nA simple [Laravel 5/6/7/8/9/10/11/12](http://www.laravel.com/) service provider for including the [Captcha for Laravel](https://github.com/mewebstudio/captcha).\n\nfor Laravel 4 [Captcha for Laravel Laravel 4](https://github.com/mewebstudio/captcha/tree/master-l4)\n\nfor Laravel 5 to 12 [Captcha for Laravel Laravel 5 and Newer versions](https://github.com/mewebstudio/captcha/tree/master-l5-l9)\n\n## Preview\n![Preview](https://image.ibb.co/kZxMLm/image.png)\n\n- [Captcha for Laravel 5/6/7/8/9/10/11/12](#captcha-for-laravel-5-6-7)\n  * [Preview](#preview)\n  * [Installation](#installation)\n  * [Usage](#usage)\n  * [Configuration](#configuration)\n    + [Custom settings:](#custom-settings)\n    + [Disable validation:](#disable-validation)\n  * [Example Usage](#example-usage)\n    + [Session Mode:](#session-mode)\n    + [Stateless Mode:](#stateless-mode)\n- [Return Image](#return-image)\n- [Return URL](#return-url)\n- [Return HTML](#return-html)\n- [To use different configurations](#to-use-different-configurations)\n  * [Links](#links)\n  \n## Installation\n\nThe Captcha Service Provider can be installed via [Composer](http://getcomposer.org) by requiring the\n`mews/captcha` package and setting the `minimum-stability` to `dev` (required for Laravel 5) in your\nproject's `composer.json`.\n\n```json\n{\n    \"require\": {\n        \"laravel/framework\": \"5.0.*\",\n        \"mews/captcha\": \"~3.0\"\n    },\n    \"minimum-stability\": \"stable\"\n}\n```\n\nor\n\nRequire this package with composer:\n```\ncomposer require mews/captcha\n```\n\nUpdate your packages with ```composer update``` or install with ```composer install```.\n\nIn Windows, you'll need to include the GD2 DLL `php_gd2.dll` in php.ini. And you also need include `php_fileinfo.dll` and `php_mbstring.dll` to fit the requirements of `mews/captcha`'s dependencies.\n\n\n\n\n## Usage\n\nTo use the Captcha Service Provider, you must register the provider when bootstrapping your Laravel application. There are\nessentially two ways to do this.\n\nFind the `providers` key in `config/app.php` and register the Captcha Service Provider.\n\n```php\n    'providers' =\u003e [\n        // ...\n        'Mews\\Captcha\\CaptchaServiceProvider',\n    ]\n```\nfor Laravel 5.1+\n```php\n    'providers' =\u003e [\n        // ...\n        Mews\\Captcha\\CaptchaServiceProvider::class,\n    ]\n```\nFor Laravel 11+ you can add the provider to `bootstrap\\providers.php`.\n```php\nreturn [\n    // ...\n    Mews\\Captcha\\CaptchaServiceProvider::class\n];\n```\n\nFind the `aliases` key in `config/app.php`.\n\n```php\n    'aliases' =\u003e [\n        // ...\n        'Captcha' =\u003e 'Mews\\Captcha\\Facades\\Captcha',\n    ]\n```\nfor Laravel 5.1+\n```php\n    'aliases' =\u003e [\n        // ...\n        'Captcha' =\u003e Mews\\Captcha\\Facades\\Captcha::class,\n    ]\n```\n\nFor Laravel 11+ : you do not need to add the alias, it will be added automatically.\n\n\n## Configuration\n### Custom settings:\nTo use your own settings, publish config.\n\n```$ php artisan vendor:publish --provider=\"Mews\\Captcha\\CaptchaServiceProvider\"```\n\n`config/captcha.php`\n\n```php\nreturn [\n    'default'   =\u003e [\n        'length'    =\u003e 5,\n        'width'     =\u003e 120,\n        'height'    =\u003e 36,\n        'quality'   =\u003e 90,\n        'math'      =\u003e true,  //Enable Math Captcha\n        'expire'    =\u003e 60,    //Captcha expiration\n    ],\n    // ...\n];\n```\n### Disable validation:\nTo disable the captcha validation use `CAPTCHA_DISABLE` environment variable. e.g. **.env** config:\n\n```php\nCAPTCHA_DISABLE=true\n```\n\n\n## Example Usage\n### Session Mode:\n```php\n    // [your site path]/Http/routes.php\n    Route::any('captcha-test', function() {\n        if (request()-\u003egetMethod() == 'POST') {\n            $rules = ['captcha' =\u003e 'required|captcha'];\n            $validator = validator()-\u003emake(request()-\u003eall(), $rules);\n            if ($validator-\u003efails()) {\n                echo '\u003cp style=\"color: #ff0000;\"\u003eIncorrect!\u003c/p\u003e';\n            } else {\n                echo '\u003cp style=\"color: #00ff30;\"\u003eMatched :)\u003c/p\u003e';\n            }\n        }\n    \n        $form = '\u003cform method=\"post\" action=\"captcha-test\"\u003e';\n        $form .= '\u003cinput type=\"hidden\" name=\"_token\" value=\"' . csrf_token() . '\"\u003e';\n        $form .= '\u003cp\u003e' . captcha_img() . '\u003c/p\u003e';\n        $form .= '\u003cp\u003e\u003cinput type=\"text\" name=\"captcha\"\u003e\u003c/p\u003e';\n        $form .= '\u003cp\u003e\u003cbutton type=\"submit\" name=\"check\"\u003eCheck\u003c/button\u003e\u003c/p\u003e';\n        $form .= '\u003c/form\u003e';\n        return $form;\n    });\n```\nDetailed Example in Laravel way\nview files\n```html\n    //register.blade.php\n    \u003cimg src=\"{{ captcha_src() }}\" alt=\"captcha\"\u003e\n        \u003cdiv class=\"mt-2\"\u003e\u003c/div\u003e\n        \u003cinput \n            type=\"text\" name=\"captcha\" class=\"form-control @error('captcha') is-invalid @enderror\" placeholder=\"Please Insert Captch\"\n            \u003e\n         @error('captcha') \n         \u003cdiv class=\"invalid-feedback\"\u003e{{ $message }}\u003c/div\u003e @enderror \n```\ncontroller files\n```php\n        Validator::make($input, [\n            'name' =\u003e ['required', 'string', 'max:255'],\n            'email' =\u003e [\n                'required',\n                'string',\n                'email',\n                'max:255',\n                Rule::unique(User::class),\n            ],\n            'password' =\u003e $this-\u003epasswordRules(),\n            'captcha' =\u003e 'required|captcha'\n        ])-\u003evalidate();\n```\n### Stateless Mode:\nYou get key and img from this url\n`http://localhost/captcha/api/math`\nand verify the captcha using this method:\n```php\n    //key is the one that you got from json response\n    // fix validator\n    // $rules = ['captcha' =\u003e 'required|captcha_api:'. request('key')];\n    $rules = ['captcha' =\u003e 'required|captcha_api:'. request('key') . ',math'];\n    $validator = validator()-\u003emake(request()-\u003eall(), $rules);\n    if ($validator-\u003efails()) {\n        return response()-\u003ejson([\n            'message' =\u003e 'invalid captcha',\n        ]);\n\n    } else {\n        //do the job\n    }\n```\n\n# Return Image\n```php\ncaptcha();\n```\nor\n```php\nCaptcha::create();\n```\n\n\n# Return URL\n```php\ncaptcha_src();\n```\nor\n```\nCaptcha::src('default');\n```\n\n# Return HTML\n```php\ncaptcha_img();\n```\nor\n```php\nCaptcha::img();\n```\n\n# To use different configurations\n```php\ncaptcha_img('flat');\n\nCaptcha::img('inverse');\n```\netc.\n\nBased on [Intervention Image](https://github.com/Intervention/image)\n\n^_^\n\n## Links\n* [Intervention Image](https://github.com/Intervention/image)\n* [L5 Captcha on Github](https://github.com/mewebstudio/captcha)\n* [L5 Captcha on Packagist](https://packagist.org/packages/mews/captcha)\n* [For L4 on Github](https://github.com/mewebstudio/captcha/tree/master-l4)\n* [License](http://www.opensource.org/licenses/mit-license.php)\n* [Laravel website](http://laravel.com)\n* [Laravel Turkiye website](http://www.laravel.gen.tr)\n* [mewebstudio](https://github.com/mewebstudio/captcha)\n","funding_links":[],"categories":["Popular Packages","PHP","Biblioteki","目录","常用验证码库","Packages","图像( Imagery )"],"sub_categories":["图像 Imagery","Authentication/Security"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmewebstudio%2Fcaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmewebstudio%2Fcaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmewebstudio%2Fcaptcha/lists"}