定制 felipetti/captcha 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

felipetti/captcha

最新稳定版本:v3.0.0

Composer 安装命令:

composer require felipetti/captcha

包简介

This package is for integrating captcha service to Laravel project

README 文档

README

What it does:

This package allows you to integrate Captcha V2 or V3 to your Laravel application.

Installation:

composer require felipetti/captcha

Usage instructions:

First you publish config file:

php artisan vendor:publish --tag=captcha

Config file named captcha.php is published in config folder of root directory. Open the file and put the secret key provided by Google inside "secret_key" field.

/*
    |--------------------------------------------------------------------------
    | Secret Key
    |--------------------------------------------------------------------------
    |
    | This is the Captcha key that only back-end has.
    |
    */

    'secret_key' => ''

There are three ways of captcha service integration, assuming $captcha is the field where front-end sends captcha response:

Form request:

    use Felipetti\Captcha\Rule\CaptchaVerification;
    
    public function rules()
    {
        $captcha = ['required', 'string', new CaptchaVerification];
        
        return compact('captcha');
    }

Request validation:

Let's suppose we have a captcha controller, and we want to make validation inside:

use Felipetti\Captcha\Rule\CaptchaVerification;
use Illuminate\Http\Request;

class CaptchaController extends Controller
{
    public function __invoke(Request $request)
    {
        $request->validate(
            ['captcha' => [new CaptchaVerification]]
        );

        //...
    }
}

Validator:

use Felipetti\Captcha\Rule\CaptchaVerification;
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\Request;

class CaptchaController extends Controller
{
    public function __invoke(Request $request)
    {
        $rules  = ['captcha' => [new CaptchaVerification]];

        Validator::make($request->only('captcha'), $rules)->validate();

        //...
    }
}

Config:

Explanations in config file are quite expressive, so if you have any questions, please email guill388@hotmail.com.

Comments:

Please star me if you liked the package, it will really help me a lot.

Security:

If you discover any security-related issues, please e-mail me to the one above instead of using the issue tracker.

License:

The MIT License (MIT).

统计信息

  • 总下载量: 1.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-13