souravmsh/easy-captcha
Composer 安装命令:
composer require souravmsh/easy-captcha
包简介
A pure image-based CAPTCHA package for Laravel
README 文档
README
An easy, lightweight, pure image-based CAPTCHA package for Laravel (Requires ext-gd). No third-party APIs needed for local generation. The CAPTCHA generates standard image data dynamically directly via PHP. Also supports Google reCAPTCHA v2/v3 and Cloudflare Turnstile (Latest!).
View Landing Page & Documentation
Installation
composer require souravmsh/easy-captcha
The package is auto-discovered by Laravel. If auto-discovery is disabled, register the service provider manually (optional):
Laravel 11+ — in bootstrap/providers.php:
return [ // ... Souravmsh\EasyCaptcha\EasyCaptchaServiceProvider::class, ];
Laravel 7–10 — in config/app.php under providers:
'providers' => [ // ... Souravmsh\EasyCaptcha\EasyCaptchaServiceProvider::class, ],
Configuration
Optionally publish the configuration file to customize CAPTCHA sizes and colors:
php artisan vendor:publish --tag=easy-captcha-config
To overwrite an already published config:
php artisan vendor:publish --tag=easy-captcha-config --force
You can change the CAPTCHA type in config/easy_captcha.php, or easily turn the CAPTCHA off completely for local development/testing using your .env file:
EASY_CAPTCHA_ENABLED=false EASY_CAPTCHA_TYPE=math EASY_CAPTCHA_FONT_PATH=UbuntuMono-Regular
Bundled Fonts (Latest!)
The package now comes with built-in fonts that you can use by name in your .env or config:
IndieFlower(Default - Handwritten)SpecialElite(Typewriter style)CourierPrime(Monospace)Ubuntu-BoldUbuntuMono-RegularUbuntu-Italic
Supported types:
'random'(Alphanumeric)'math'(e.g., 5 + 3, validation checks for 8)'alphabet'(Letters only)'number'(Numbers only)'google'(Google reCAPTCHA v2/v3 support!)'turnstile'(Cloudflare Turnstile support! - Latest)
Setting up Google reCAPTCHA
If you choose google as the CAPTCHA type, our blade directive and validation facade will automatically hook into Google's APIs. If you want to use older version like v3 then spefify in config file, default is v3. Add your site/secret keys inside the .env:
EASY_CAPTCHA_TYPE=google EASY_CAPTCHA_GOOGLE_API_VERSION=3 EASY_CAPTCHA_GOOGLE_SITE_KEY=your-site-key-here EASY_CAPTCHA_GOOGLE_SECRET_KEY=your-secret-key-here
Setting up Cloudflare Turnstile (Latest!)
If you choose turnstile as the CAPTCHA type, our blade directive and validation facade will automatically hook into Cloudflare's APIs. Add your site/secret keys inside the .env:
EASY_CAPTCHA_TYPE=turnstile EASY_CAPTCHA_TURNSTILE_SITE_KEY=your-site-key-here EASY_CAPTCHA_TURNSTILE_SECRET_KEY=your-secret-key-here
Usage
Displaying the CAPTCHA image
In your Blade form, you can render an image tag manually:
@easyCaptcha
This simple blade directive handles showing the <img /> and attaching a neat [Reload] button next to it!
Or you can use the Facade manually if you need more control:
{!! \Souravmsh\EasyCaptcha\Facades\EasyCaptcha::img(['class' => 'my-captcha-class']) !!}
Validating the CAPTCHA
Once the form is submitted, validate the user's input:
use Illuminate\Http\Request; use Souravmsh\EasyCaptcha\Rules\Captcha; public function submit(Request $request) { // Option 1: String rule (Standard) $request->validate([ 'captcha' => 'required|easyCaptcha' ]); // Option 2: Class-based rule (More robust) $request->validate([ 'captcha' => ['required', new Captcha] ]); // Option 3: Alias rule (More robust) $request->validate([ 'captcha' => 'required|captcha' ]); // Option 4: Alias rule (More robust) $request->validate([ 'captcha' => 'required|easy_captcha' ]); // Success! return "Valid CAPTCHA!"; }
Support
Laravel versions 7, 8, 9, 10, 11, 12, 13 are fully supported.
PHP 7.2.5+ & 8.0+ are required along with ext-gd.
souravmsh/easy-captcha 适用场景与选型建议
souravmsh/easy-captcha 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「security」 「validation」 「google」 「captcha」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 souravmsh/easy-captcha 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 souravmsh/easy-captcha 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 souravmsh/easy-captcha 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
Provide a way to secure accesses to all routes of an symfony application.
It's a barebone security class written on PHP
The Yii2 extension uses jQuery PrettyPhoto and OwlCarousel js and makes image galary from php array of structure defined.
Adds request-parameter validation to the SLIM 3.x PHP framework
统计信息
- 总下载量: 44
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-06