anselmh/kirby-uniform-turnstile
Composer 安装命令:
composer require anselmh/kirby-uniform-turnstile
包简介
Kirby 3 Cloudflare Turnstile guard for the Uniform plugin
README 文档
README
A Kirby 3 plugin implementing a Cloudflare Turnstile guard for the Uniform plugin.
Installation
Composer
Add the plugin to your project:
composer require anselmh/kirby-uniform-turnstile
Manual install
It is possible to install plugins manually. Download from the Github Releases page, unpack the archive and put it into site/plugins.
Please note that this project depends on Uniform so it is required to install this package as well.
Configuration
Set the configuration in your config.php file:
return [ 'anselmh.uniform-turnstile.siteKey' => 'my-site-key', 'anselmh.uniform-turnstile.secretKey' => 'my-secret-key', 'anselmh.uniform-turnstile.theme' => 'auto(default)|light|dark', ];
Usage
Template
You can use the provided helper function to embed the Turnstile into your template:
<?= turnstileField() ?>
In order for turnstile to work, you need to provide the Turnstile JavaScript file.
Use the helper function turnstileScript() in your template or add it to the template at right before the closing </body> tag.
Example
<form action="<?= $page->url() ?>" method="post"> <label for="name" class="required">Name</label> <input<?php if ($form->error('name')): ?> class="erroneous"<?php endif; ?> name="name" type="text" value="<?= $form->old('name') ?>"> <!-- ... --> <?= csrf_field() ?> <?= turnstileField() ?> <input type="submit" value="Submit"> </form> <?= turnstileScript() ?>
Controller
In your controller you can use the magic method turnstileGuard() to enable the turnstile guard:
$form = new Form(/* ... */); if ($kirby->request()->is('POST')) { $form->turnstileGuard() ->emailAction(/* ... */); }
Credits
- Thanks to Lukas Dürrenberger for the Uniform reCAPTCHA Guard Plugin
- Thanks to Lukas Leitsch for the Uniform hCaptcha Guard Plugin
anselmh/kirby-uniform-turnstile 适用场景与选型建议
anselmh/kirby-uniform-turnstile 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.78k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2022 年 11 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 anselmh/kirby-uniform-turnstile 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 anselmh/kirby-uniform-turnstile 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.78k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-10