inthinking/cloudflare-turnstile-bundle
Composer 安装命令:
composer require inthinking/cloudflare-turnstile-bundle
包简介
Fork updated with support for PHP 8.5 and Symfony 8.0 - Extensible and configurable integration of Cloudflare Turnstile with Symfony
README 文档
README
Requires Symfony >= 5.0 and PHP >= 7.4. Tested up to Symfony 8.
The purpose of this bundle is to facilitate the configuration and integration of the Cloudflare Turnstile captcha system into Symfony forms.
Summary of features provided:
- Automatic captcha rendering, language configuration and validation
- Timeout management
- Client-side error domain management
- reCAPTCHA / hCaptcha compatibility mode
- Possibility of using custom JavaScript rendering logic
- Possibility of marking captchas as required
Get started
With Symfony Flex
Run the following command with Composer:
composer require inthinking/cloudflare-turnstile-bundle
If you have not explicitly allowed "contrib" recipes in your composer.json file, you will be prompted with the following message for inthinking/cloudflare-turnstile-bundle:
Do you want to execute this recipe?
Answer yes for inthinking/cloudflare-turnstile-bundle.
Finally, modify the inthinking/cloudflare-turnstile-bundle section of the .env file to add your Cloudflare Turnstile application keys:
###> inthinking/cloudflare-turnstile-bundle ###
CLOUDFLARE_TURNSTILE_SITEKEY=<sitekey>
CLOUDFLARE_TURNSTILE_SECRET_KEY=<secret_key>
###< inthinking/cloudflare-turnstile-bundle ###
Without Symfony Flex
Install Composer dependencies:
composer require inthinking/cloudflare-turnstile-bundle
Register the bundle inside the config/bundles.php file:
return [ //... Zemasterkrom\CloudflareTurnstileBundle\ZmkrCloudflareTurnstileBundle::class => ['all' => true], ];
Create the config/packages/zmkr_cloudflare_turnstile.yaml configuration file:
zmkr_cloudflare_turnstile: captcha: sitekey: "%env(CLOUDFLARE_TURNSTILE_SITEKEY)%" secret_key: "%env(CLOUDFLARE_TURNSTILE_SECRET_KEY)%"
Add your Cloudflare Turnstile application keys to the .env file:
CLOUDFLARE_TURNSTILE_SITEKEY=<sitekey>
CLOUDFLARE_TURNSTILE_SECRET_KEY=<secret_key>
Usage
To add a Cloudflare Turnstile captcha to a form, you need to associate a CloudflareTurnstileType field in your form builder:
<?php namespace App\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Zemasterkrom\CloudflareTurnstileBundle\Form\Type\CloudflareTurnstileType; class ContactType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('first_name', TextType::class, [ 'label' => 'First name' ]) ->add('last_name', TextType::class, [ 'label' => 'Last name' ]) ->add('cf_turnstile_response', CloudflareTurnstileType::class); } }
Validation will be performed automatically when you check the form that is associated with a CloudflareTurnstileType:
<?php namespace App\Controller; use App\Form\Type\ContactType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class CloudflareTurnstileTestController extends AbstractController { public function validateContactForm(Request $request): Response { $form = $this->createForm(ContactType::class); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { // The form has been submitted and is valid: execute your actions here } // The form has not been submitted or is invalid: if there is an error, an error message will be registered in your form return $this->render('<twig_template_path>', [ 'form' => $form->createView(), ]); } }
Documentation
For advanced usage, please see the documentation.
License
This bundle is licensed under the MIT license. The license is accessible here.
inthinking/cloudflare-turnstile-bundle 适用场景与选型建议
inthinking/cloudflare-turnstile-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 532 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「form」 「spam」 「captcha」 「cloudflare」 「anti-spam」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 inthinking/cloudflare-turnstile-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inthinking/cloudflare-turnstile-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 inthinking/cloudflare-turnstile-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple captcha generator
reCAPTCHA library
Client library for reCAPTCHA with proxy support, a free service that protects websites from spam and abuse.
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
Provide a way to secure accesses to all routes of an symfony application.
It's a barebone security class written on PHP
统计信息
- 总下载量: 532
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-13