astritzeqiri/g-recaptcha
Composer 安装命令:
composer require astritzeqiri/g-recaptcha
包简介
Easily add google recaptcha
README 文档
README
Google recaptcha for Laravel
Easily add google recaptcha in Laravel.
Requirements
- PHP >=5.4
- Laravel >= 5.0
- GuzzleHttp >= 5.3
Installation
Add astritzeqiri/g-recaptcha to your composer.json file:
"require": { "astritzeqiri/g-recaptcha": "~1.0" }
And do:
$ composer update
Or get composer to install the package:
$ composer require astritzeqiri/g-recaptcha
Configuration
Now you go and generate a new Google recaptcha on the link below:
Then you go to your .env file and set these variables
# If you want to disable captchas put this to false by default this is true.
GRECAPTCHA_ENABLED=true
# The google recaptcha site key
GRECAPTCHA_KEY=SITE_KEY
# The google recaptcha secret key
GRECAPTCHA_SECRET=SECRET_KEY
You can also change these variables on the config file on config/grecaptcha.php file.
return [ 'enabled' => env("GRECAPTCHA_ENABLED", true), 'site_key' => env("GRECAPTCHA_KEY"), 'secret_key' => env("GRECAPTCHA_SECRET"), ];
Registering the Package
Register the service provider within the providers array found in app/config/app.php:
'providers' => array( // ... AstritZeqiri\GRecaptcha\GRecaptchaServiceProvider::class )
Then you need to add GRecaptcha class within the aliases array found in app/config/app.php:
'aliases' => array( // ... 'GRecaptcha' => AstritZeqiri\GRecaptcha\GRecaptcha::class, )
Then you run php artisan vendor:publish to publish the start_captchas script and also the recaptcha config file.
$ php artisan vendor:publish
Usage
First of all you need to call the grecaptcha scripts on the footer. The scripts are rendered only if you have an active captcha somewhere on you html.
// in blade.php files {!! \GRecaptcha::renderScripts() !!} // or in .php files <?php echo GRecaptcha::renderScripts(); ?>
Basic Example
Now to render a new GRecaptcha you call the render method.
// by default it echo's it out GRecaptcha::render(); // if you want to save the html in a variable you call $grecaptchaHtml = GRecaptcha::render([], false);
If you want to get a new recaptcha instance:
$grecaptcha = GRecaptcha::generate(); // to render it you call $grecaptcha->renderHtml(); // if you dont want it to be rendered but store the html you call $grecaptchaHtml = $grecaptcha->build();
Validation
When you validate a form to validate the recaptcha you use the rule grecaptcha
$validator = Validator::make($inputs, ['g-recaptcha-response' => 'required|grecaptcha'] );
License
astritzeqiri/g-recaptcha 适用场景与选型建议
astritzeqiri/g-recaptcha 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Authentication」 「laravel」 「Google ReCaptcha」 「g-recaptcha」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 astritzeqiri/g-recaptcha 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 astritzeqiri/g-recaptcha 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 astritzeqiri/g-recaptcha 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
Email Toolkit Plugin for CakePHP
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-26