greggilbert/recaptcha
最新稳定版本:2.2.0
Composer 安装命令:
composer require greggilbert/recaptcha
包简介
reCAPTCHA Validator for Laravel 5
README 文档
README
All good things must come to an end. The sad fact is that I don't have time to maintain this package, so the release of Laravel 6 is as good as any to make a clean break. You should take a look at the forks to see if anyone is carrying on the torch.
Thanks to everyone for sticking by this package for years!
Recaptcha
A reCAPTCHA Validator for Laravel 5.
(Looking for a Laravel 4 version? Pull the latest 1.x tag. For Laravel 5.0, pull the latest 2.0 tag.)
Installation
Add the following line to the require section of composer.json:
{
"require": {
"greggilbert/recaptcha": "dev-master"
}
}
Setup
- In
/config/app.php, add the following toproviders:
Greggilbert\Recaptcha\RecaptchaServiceProvider::class,
and the following to aliases:
'Recaptcha' => Greggilbert\Recaptcha\Facades\Recaptcha::class,
- Run
php artisan vendor:publish --provider="Greggilbert\Recaptcha\RecaptchaServiceProvider". - In
/config/recaptcha.php, enter your reCAPTCHA public and private keys.
- If you are not using the most recent version of reCAPTCHA, set
versionto 1. - If you are upgrading to v2 of reCAPTCHA, note that your keys from the previous version will not work, and you need to generate a new set in the reCAPTCHA admin.
- The package ships with a default validation message, but if you want to customize it, add the following line into
resources/lang/[lang]/validation.php:
'recaptcha' => 'The :attribute field is not correct.',
Usage
v2 (No Captcha)
- In your form, use
{!! Recaptcha::render() !!}to echo out the markup. - In your validation rules, add the following:
$rules = [ // ... 'g-recaptcha-response' => 'required|recaptcha', ];
v1 (Legacy)
- In your form, use
{!! Recaptcha::render() !!}to echo out the markup. - In your validation rules, add the following:
$rules = [ // ... 'recaptcha_response_field' => 'required|recaptcha', ];
It's also recommended to add required when validating.
Customization
reCAPTCHA v2 allows for customization of the widget through a number of options, listed at the official documentation. You can configure the output of the captcha through six allowed keys: theme, type, lang, callback, tabindex and expired-callback.
In the config file, you can create an options array to set the default behavior. For example:
// ... 'options' => [ 'lang' => 'ja', ],
would default the language in all the reCAPTCHAs to Japanese. If you want to further customize, you can pass options through the render option:
echo Recaptcha::render([ 'lang' => 'fr' ]);
Options passed into Recaptcha::render will always supercede the configuration.
Language
To change the language of the captcha, simply pass in a language as part of the options:
'options' => [ 'lang' => 'fr', ],
For a list of valid language codes, consulting the official documentation.
Custom template
Alternatively, if you want to set a default template instead of the standard one, you can use the config:
// ... 'template' => 'customCaptcha',
or you can pass it in through the Form option:
echo Recaptcha::render([ 'template' => 'customCaptcha' ]);
v1 customization
For the v1 customization options, consult the old documentation and apply accordingly.
Limitation
Because of Google's way of displaying the reCAPTCHA, this package won't work if you load your form from an AJAX call. If you need to do it, you should use one of the alternate methods provided by Google.
greggilbert/recaptcha 适用场景与选型建议
greggilbert/recaptcha 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.5M 次下载、GitHub Stars 达 727, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「recaptcha」 「captcha」 「laravel」 「laravel5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 greggilbert/recaptcha 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 greggilbert/recaptcha 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 greggilbert/recaptcha 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Client library for reCAPTCHA with proxy support, a free service that protects websites from spam and abuse.
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
A simple and easy to use Google ReCaptcha v3 package for Laravel
Two Captcha
Laravel 5 Securimage helper
CakePHP Captcha Plugin, Image, Math and Google Recaptcha Support
统计信息
- 总下载量: 1.5M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 745
- 点击次数: 33
- 依赖项目数: 18
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04