{"id":18537957,"url":"https://github.com/shetabit/captcha","last_synced_at":"2025-06-28T08:38:37.423Z","repository":{"id":57049268,"uuid":"170646689","full_name":"shetabit/captcha","owner":"shetabit","description":"laravel captcha supports multiple drivers","archived":false,"fork":false,"pushed_at":"2019-03-04T09:09:36.000Z","size":104,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T10:46:19.696Z","etag":null,"topics":["captcha","captcha-generator","laravel-captcha","simple-laravel-captcha"],"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/shetabit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-14T07:25:46.000Z","updated_at":"2019-10-29T21:26:27.000Z","dependencies_parsed_at":"2022-08-23T17:50:25.607Z","dependency_job_id":null,"html_url":"https://github.com/shetabit/captcha","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/shetabit/captcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fcaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fcaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fcaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fcaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shetabit","download_url":"https://codeload.github.com/shetabit/captcha/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fcaptcha/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262402682,"owners_count":23305659,"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-generator","laravel-captcha","simple-laravel-captcha"],"created_at":"2024-11-06T19:41:27.442Z","updated_at":"2025-06-28T08:38:37.407Z","avatar_url":"https://github.com/shetabit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Captcha\n\nThis packages works with multiple drivers, \nand you can create custom drivers if there are not available in the \ncurrent drivers list (below list).\n\n# Laravel Captcha\n\n[![Software License][ico-license]](LICENSE.md)\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Quality Score][ico-code-quality]][link-code-quality]\n\nThis is a Laravel Package for captcha Integration. This package supports `Laravel 5.4+`.\n\n\u003e This packages works with multiple drivers, and you can create custom drivers if there are not available in the [current drivers list](#list-of-available-drivers) (below list).\n\n# List of contents\n\n- [Available drivers](#list-of-available-drivers)\n- [Install](#install)\n- [Configure](#configure)\n- [How to use](#how-to-use)\n  - [Add captcha in forms](#add-captcha-in-forms)\n  - [Validation](#validation)\n  - [Create custom drivers](#create-custom-drivers)\n- [Change log](#change-log)\n- [Contributing](#contributing)\n- [Security](#security)\n- [Credits](#credits)\n- [License](#license)\n\n# List of available drivers\n\n- Simple : a simple image captcha.\n- Others are under way.\n\n\u003e you can create your own custom driver if not  exists in the list , read the `Create custom drivers` section.\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require shetabit/captcha\n```\n\n## Configure\n\nIf you are using `Laravel 5.5` or higher then you don't need to add the provider and alias.\n\nIn your `config/app.php` file add these two lines.\n\n```php\n# In your providers array.\n'providers' =\u003e [\n    ...\n    Shetabit\\Captcha\\Provider\\CaptchaServiceProvider::class,\n],\n\n# In your aliases array.\n'aliases' =\u003e [\n    ...\n    'Payment' =\u003e Shetabit\\Captcha\\Facade\\Captcha::class,\n],\n```\n\nthen run `php artisan vendor:publish` to publish `config/captcha.php` file in your config directory.\n\nIn the config file you can set the `default driver` to use for all your payments. But you can also change the driver at runtime.\n\nChoose what gateway you would like to use in your application. Then make that as default driver so that you don't have to specify that everywhere. But, you can also use multiple gateways in a project.\n\n```php\n// Eg. if you want to use simple. (simple is the driver's name)\n'default' =\u003e 'simple',\n```\n\nThen see the configs in the drivers array.\n\n```php\n'drivers' =\u003e [\n    'simple' =\u003e [\n        'middleware' =\u003e ['web'], // middleware\n        'route' =\u003e 'captcha', // route name\n        'characters' =\u003e 'ABCDEFGHIKJLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789',\n        'width'  =\u003e 230,\n        'height' =\u003e 70,\n        'foregroundColors' =\u003e ['2980b9','2E9FFF','FF1166','000000','22EE99'],\n        'backgroundColor' =\u003e '#FFF',\n        'letterSpacing' =\u003e 6,\n        'fontFamily' =\u003e resource_path('views/vendor/captchaSimpleDriver/assets/fonts/DroidSerif.ttf'),\n        'fontSize' =\u003e 30,\n        'length' =\u003e [4, 6],\n        'scratches' =\u003e [5, 8],\n        'sensitive' =\u003e false,\n        'sessionKey' =\u003e 'captcha',\n    ],\n    ...\n]\n```\n\n## How to use\n\nyou have 2 steps to go\n\n- add captcha in forms\n- add validation\n\n#### Add captcha in forms\n\nIn your code, use it like the below:\n\n```php\n\u003cform\u003e\n...\n\n{!! captcha() !!}\n\n...\n\u003c/form\u003e\n```\n\nif you use `simple` driver, you can change the styles and UI easily,\njust have a look on `resources/views/vendor/captchaSimpleDriver.blade.php`\n\n#### Validation\nin order to validate forms wich use captcha, you can use `captcha` validation role.\n\nThe below example shows every thing you need to know about captcha validation:\n\n```php\n...\n\n$request-\u003evalidate([\n    'email' =\u003e 'required|email',\n    'password' =\u003e 'required|string',\n    'captcha' =\u003e 'required|captcha',\n]);\n\n...\n```\n\n#### Create custom drivers:\n\nFirst you have to add the name of your driver, in the drivers array and also you can specify any config parameters you want.\n\n```php\n'drivers' =\u003e [\n    'simple' =\u003e [...],\n    'my_driver' =\u003e [\n        ... # Your Config Params here.\n    ]\n]\n```\n\nNow you have to create a Driver Map Class that will be used to pay invoices.\nIn your driver, You just have to extend `Shetabit\\Captcha\\Abstracts\\Driver`.\n\nEx. You created a class : `App\\Packages\\CaptchaDriver\\MyDriver`.\n\n```php\nnamespace App\\Packages\\CaptchaDriver;\n\nuse Illuminate\\Support\\ServiceProvider;\nuse Shetabit\\Captcha\\Abstracts\\Driver;\n\nclass MyDriver extends Driver\n{\n    protected $serviceProvider;\n\n    /**\n     * Driver settings.\n     *\n     * @var object\n     */\n    protected $settings;\n\n    public function __construct(ServiceProvider $serviceProvider, $settings)\n    {\n        $this-\u003eserviceProvider = $serviceProvider;\n        $this-\u003esettings = (object) $settings;\n    }\n    \n    /**\n        you must write your captcha generation \n        logic in the below method.\n    **/\n    public function generate()\n    {\n        ...\n    \n        // create captcha view and return it\n        return View::make('yourCustomDriverView');\n    }\n\n    /**\n        you must write your captcha verification\n        logic in the below method.\n    **/\n    public function verify($token = null)\n    {\n        ...\n    \n        $storedToken = ...\n\n        if (empty($this-\u003esettings-\u003esensitive)) {\n            $storedToken = mb_strtolower($storedToken);\n            $token = mb_strtolower($token);\n        }\n\n        return $token == $storedToken;\n    }\n    \n}\n```\n\nOnce you create that class you have to specify it in the `captcha.php` config file `map` section.\n\n```php\n'map' =\u003e [\n    ...\n    'my_driver' =\u003e App\\Packages\\CaptchaDriver\\MyDriver::class,\n]\n```\n\n**Note:-** You have to make sure that the key of the `map` array is identical to the key of the `drivers` array.\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email hashemm364@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Hashem Moghaddari][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/shetabit/captcha.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/shetabit/captcha.svg?label=Code%20Quality\u0026style=flat-square\n\n[link-packagist]: https://packagist.org/packages/shetabit/captcha\n[link-code-quality]: https://scrutinizer-ci.com/g/shetabit/captcha\n[link-author]: https://github.com/hamog\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshetabit%2Fcaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshetabit%2Fcaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshetabit%2Fcaptcha/lists"}