承接 sooluh/codeigniter4-recaptcha 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sooluh/codeigniter4-recaptcha

最新稳定版本:0.0.2

Composer 安装命令:

composer require sooluh/codeigniter4-recaptcha

包简介

CodeIgniter 4 verifier for Google reCAPTCHA v2 and reCAPTCHA v3

README 文档

README

I stand with Palestine

CodeIgniter 4 reCAPTCHA

Latest Stable Version Total Downloads Latest Unstable Version License

CodeIgniter 4 verifier for Google reCAPTCHA v2 and reCAPTCHA v3.

Requirements

  • PHP >= 7.4
  • Composer

Features

  • PSR-4 autoloading compliant structure
  • PSR-2 compliant code style
  • Useful tools for better code included

Installation

Install the package with:

composer require sooluh/codeigniter4-recaptcha

Configuration

Add your reCAPTCHA keys to the .env file.

# --------------------------------------------------------------------
# ReCaptcha 2
# --------------------------------------------------------------------
recaptcha2.key = 'XXXXXXXX-XXXXXXXX'
recaptcha2.secret = 'XXXXXXXX-XXXXXXXX'

# --------------------------------------------------------------------
# ReCaptcha 3
# --------------------------------------------------------------------
recaptcha3.key = 'XXXXXXXX-XXXXXXXX'
recaptcha3.secret = 'XXXXXXXX-XXXXXXXX'
recaptcha3.scoreThreshold = 0.5

In the /app/Config/Validation.php file, you need to add settings for the validator.

public $ruleSets = [
    ...
    \ReCaptcha\Validation\ReCaptchaRules::class
];

Usage

Rendering reCAPTCHA v2

helper(['form', 'reCaptcha']);

echo form_open();

echo reCaptcha2('reCaptcha2', ['id' => 'recaptcha_v2'], ['theme' => 'dark']);

echo form_submit('submit', 'Submit');

echo form_close();

Rendering reCAPTCHA v3

helper(['form', 'reCaptcha']);

echo form_open();

echo reCaptcha3('reCaptcha3', ['id' => 'recaptcha_v3'], ['action' => 'contactForm']);

echo form_submit('submit', 'Submit');

echo form_close();

Validation

public $validationRules = [
    'reCaptcha2' => 'required|reCaptcha2[]',
    'reCaptcha3' => 'required|reCaptcha3[contactForm,0.9]'
    ....
];

In the settings of the reCaptcha3 validator, the first parameter you specify is expectedAction, this parameter is not required.
You can override a global scoreThreshold parameter in the second reCaptcha3 rule parameter.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

This project is built upon the foundation of codeigniter4-recaptcha repository created by denis303. The decision to use this basecode was motivated by its robust architecture and existing functionalities.

Note

Please note that the original repository might not have been active for the past 2 years and the original developer's GitHub profile indicates limited recent activity.

Disclaimer

This project has been modified to address certain issues and to suit the requirements of this project.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-21