laercionunesc/captcha-cf 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

laercionunesc/captcha-cf

最新稳定版本:v1.0.0

Composer 安装命令:

composer require laercionunesc/captcha-cf

包简介

Easily use Turnstile Cloudflare plugin for CakePHP

README 文档

README

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require laercionunesc/captcha-cf

followed by the command:

composer update

Load plugin

From command line:

bin/cake plugin load CaptchaCf

OR load in config/bootstrap.php

Plugin::load('CaptchaCf', ['bootstrap' => false, 'autoload' => true]);

Load Component and Configure

Override default configure from loadComponent in Controller:

$this->loadComponent('CaptchaCf.CaptchaCf', [
    'enable' => true,
    'sitekey' => 'key-public', // get credentials in https://developers.cloudflare.com/turnstile/get-started/#existing-sites
    'secret' => 'key-secret',
    'size' => 'flexible',
    'theme' => 'auto',
    'language' => 'en'
]);

Usage

Display Captcha Turnstile in your view:

    <?= $this->Form->create() ?>
    <?= $this->Form->control('username') ?>
    <?= $this->Form->control('password') ?>
    <?= $this->CaptchaCf->display() ?>  // Display Captcha Turnstile box in your view, if configure has enable = false, nothing will be displayed
    <?= $this->Form->button() ?>
    <?= $this->Form->end() ?>

Verify in your controller function

    public function login()
    {
        if ($this->request->is('post')) {
            if ($this->CaptchaCf->verify()) { // if configure enable = false, it will always return true
                //do something here
            }
            $this->Flash->error(__('Please pass Turnstile first'));
        }
    }

Done!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-15