talent-loom/laravel-recaptcha-v3
Composer 安装命令:
composer require talent-loom/laravel-recaptcha-v3
包简介
PHP package for reCAPTCHA v3 in Laravel
README 文档
README
Laravel ReCAPTCHA V3 is a very simply-to-use Laravel 9.x | 10.x | 11.x package to embed Google reCAPTCHA in your application.
What is reCAPTCHA?
Google offers reCAPTCHA v3 and reCAPTCHA Enterprise to help you protect your sites from fraudulent activities, spam, and abuse. To know more about the features of reCAPTCHA and reCAPTCHA Enterprise, see Comparison of features between reCAPTCHA versions.
You can find further info at Google reCAPTCHA Developer's Guide
reCAPTCHA available versions
At this moment there are 3 versions available (for web applications):
- v3, the latest (reCAPTCHA v3)
- v2 checkbox or simply reCAPTCHA v2 (reCAPTCHA v2)
- v2 invisible (Invisible reCAPTCHA)
Get your key first!
First of all you have to create your own API keys here
Follow the instructions and at the end of the process you will find Site key and Secret key. Keep them close..you will need soon!
System requirements
| Package version | reCaptcha version | PHP version | Laravel version |
|---|---|---|---|
| v9.0.0 | v3 | 8.0.2 or greater | 9.x |
| v10.0.0 | v3 | 8.1 or greater | 10.x |
| v11.0.0 | v3 | 8.2 or greater | 11.x |
Composer
You can install the package via composer:
$ composer require talent-loom/laravel-recaptcha-v3
Configuration for LARAVEL 9.x | 10.x
Laravel 9.x or 10.x registered providers in config/app.php:
'providers' => [ ... TalentLoom\RecaptchaV3\RecaptchaV3ServiceProvider::class, ];
You can use the facade for shorter code. Add ReCaptchaV3 to your aliases:
'aliases' => [ ... 'ReCaptchaV3' => TalentLoom\RecaptchaV3\Facades\RecaptchaV3::class, ];
Configuration for LARAVEL 11.x
Laravel 11.x registered providers in bootstrap/providers.php:
return [ App\Providers\AppServiceProvider::class, TalentLoom\RecaptchaV3\RecaptchaV3ServiceProvider::class, ];
You can use the facade for shorter code. Add ReCaptchaV3 to your aliases in config/app.php:
return [ .... 'aliases' => Facade::defaultAliases()->merge([ 'ReCaptchaV3' => TalentLoom\RecaptchaV3\Facades\RecaptchaV3::class, ])->toArray(), ];
Publish package
Create config/recaptchaV3.php configuration file using the following artisan command:
$ php artisan vendor:publish --provider="TalentLoom\RecaptchaV3\RecaptchaV3ServiceProvider"
Environment Variables
To run this project, you will need to add the following environment variables to your .env file
RECAPTCHA_V3_SITE_KEY
RECAPTCHA_V3_SECRET_KEY
Reload config cache file
!!! IMPORTANT !!! Every time you change some configuration run the following shell command:
$ php artisan config:cache
Implementation
Add validation in request
use TalentLoom\RecaptchaV3\Rules\RecaptchaV3Rule; [ ... 'recaptcha_v3' => new RecaptchaV3Rule(), ];
Embed in Blade
Insert js() script before closing </head> tag.
You can also use ReCaptchaV3::js().
<!DOCTYPE html> <html> <head> ... {!! ReCaptchaV3::js() !!} </head>
Now you can use ReCaptchaV3::execute('action', 'form id').
like:
<form action="..." method="POST" id="loginForm"> @csrf .... </form>
{!! ReCaptchaV3::execute('login-action', 'loginForm') !!} </body> </html>
Running Tests
To run tests, run the following command
./vendor/bin/pest
Authors
Support
For support, email syedshazeedul@gmail.
License
talent-loom/laravel-recaptcha-v3 适用场景与选型建议
talent-loom/laravel-recaptcha-v3 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 08 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 talent-loom/laravel-recaptcha-v3 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 talent-loom/laravel-recaptcha-v3 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-10