friendsofhyperf/recaptcha
最新稳定版本:v3.2.0-alpha.6
Composer 安装命令:
composer require friendsofhyperf/recaptcha
包简介
The Google recaptcha component for Hyperf.
README 文档
README
The Google recaptcha component for Hyperf.
Installation
- Request
composer require friendsofhyperf/recaptcha
Usage
- Middleware
namespace App\Middleware; use FriendsOfHyperf\ReCaptcha\Middleware\ReCaptchaMiddleware; class V3CaptchaMiddleware extends ReCaptchaMiddleware { protected string $version = 'v3'; protected string $action = 'register'; protected float $score = 0.35; protected string $hostname; } class V2CaptchaMiddleware extends ReCaptchaMiddleware { protected string $version = 'v2'; protected string $action = 'register'; protected float $score = 0.35; protected string $hostname; }
- Validator
<?php namespace App\Controller; use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\Validation\Contract\ValidatorFactoryInterface; class IndexController { #[Inject] protected ValidatorFactoryInterface $validationFactory; public function foo(RequestInterface $request) { $validator = $this->validationFactory->make( $request->all(), [ 'g-recaptcha' => 'required|recaptcha:register,0.34,hostname,v3', ], [ 'g-recaptcha.required' => 'g-recaptcha is required', 'g-recaptcha.recaptcha' => 'Google ReCaptcha Verify Fails', ] ); if ($validator->fails()){ // Handle exception $errorMessage = $validator->errors()->first(); } // Do something } }
Contact
License
统计信息
- 总下载量: 1.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-08