定制 joukhar/laravel-no-captcha-v3 二次开发

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

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

joukhar/laravel-no-captcha-v3

最新稳定版本:1.0

Composer 安装命令:

composer require joukhar/laravel-no-captcha-v3

包简介

Laravel no captcha v3 is a light weight package to add google recaptcha v3 to your sensitive pages in laravel applications

README 文档

README

License Total Downloads Isues

Installation

Add the new required package in your composer.json

"joukhar/laravel-no-captcha-v3": "^1.0"

Run composer update or php composer.phar update.

Or install directly via composer

composer require joukhar/laravel-no-captcha-v3

Requirements

Require php >= 7.4

Configuration

You can override the default options for The Package. First publish the configuration:

php artisan vendor:publish --provider="Joukhar\LaravelNoCaptchaV3\LaravelNoCaptchaV3" --tag=laravel-no-captcha-v3-config

then Add The following keys to .env file to turn on/off the recaptcha ex:

ENABLE_NO_CAPTCHA=on
GOOGLE_RECAPTCHA_SITE_KEY=
GOOGLE_RECAPTCHA_SECRET_KEY=

And Add your Recaptcha Credentials in the config file:

     'recaptcha' => [
        'site_key' => env('GOOGLE_RECAPTCHA_SITE_KEY'),
        'secret_key' => env('GOOGLE_RECAPTCHA_SECRET_KEY')
    ]

you can get them here https://www.google.com/u/1/recaptcha/admin/create

Views

If You want to override the default views, you can publish them via:

php artisan vendor:publish --provider="Joukhar\LaravelNoCaptchaV3\LaravelNoCaptchaV3" --tag=laravel-no-captcha-v3-views

Usage

in the routes file (web.php)

Route::post('submit-form', [TestController::class, 'handleFormSubmission']);

in the blade file

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

    <form action="{{ route('validate-form') }}" method="post">
        @csrf
        @include('NoCaptchaV3::recaptcha-input')

        <button type="submit">Submit Form</button>
    </form>


    {{--  --------------------------------------------------------------------  --}}
    {{-- Your Scripts                                                           --}}
    {{--  --------------------------------------------------------------------  --}}
    @include('NoCaptchaV3::recaptcha-script')

</body>

</html>

in the controller which associated with previous blade file

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Joukhar\LaravelNoCaptchaV3\Http\Controllers\NoCaptchaV3Controller;

class TestController extends Controller
{
    public function handleFormSubmission(Request $request, NoCaptchaV3Controller $noCaptchaV3Controller)
    {
        $request->validate([
            'recaptcha' => 'required'
        ]);
        // if reCaptcha Validation has Failed, it will return 'Google reCaptcha Validation has Failed';
        // if reCaptcha score >= 0.5, it will return 'safe' otherwise it will return 'not safe' ;
        // if ENABLE_NO_CAPTCHA = off , it will return 'false' ;

        $recaptchaResult = $noCaptchaV3Controller->reCaptchaResponse();
    
        // conclusion
        if ($recaptchaResult == 'safe') {
            // your code
        }
    }
}

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 55
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固