定制 artack/recaptcha-enterprise-bundle 二次开发

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

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

artack/recaptcha-enterprise-bundle

Composer 安装命令:

composer require artack/recaptcha-enterprise-bundle

包简介

Symfony integration for Google reCAPTCHA Enterprise (Assessments API)

README 文档

README

Symfony integration for Google reCAPTCHA Enterprise (Assessments API).

Latest Release MIT License Total Downloads

Developed by ARTACK WebLab GmbH in Zurich, Switzerland.

Features

  • Provides the RecaptchaEnterpriseType form type that renders the hidden token field, loads the Google script and submits the token transparently.
  • Ships a RecaptchaEnterprise validation constraint for attributes and PHP configuration, including configurable score threshold and action names.
  • Automatically resolves client IP and User-Agent from Symfony's request stack and forwards them to Google when available.
  • Registers the form theme automatically, so no manual Twig configuration is required.

Installation

Install the bundle via Composer:

$ composer require artack/recaptcha-enterprise-bundle

The bundle is auto-registered thanks to Symfony Flex support.

⚠️ This bundle is being used in production, but hasn't reached version 1.0 yet. Therefore, there can be breaking changes between minor versions. I'd recommend that you require the bundle only with the current minor version like composer require artack/recapture-bundle:0.1.*

Configuration

Create config/packages/artack_recaptcha_enterprise.yaml with your Google project credentials:

# config/packages/artack_recaptcha_enterprise.yaml
artack_recaptcha_enterprise:
    enabled: '%env(resolve:ARTACK_GOOGLE_RECAPTCHA_ENABLED)%' # defaults to true
    site_key: '%env(resolve:ARTACK_GOOGLE_RECAPTCHA_SITE_KEY)%'
    project_id: '%env(resolve:ARTACK_GOOGLE_RECAPTCHA_PROJECT_ID)%'
    api_key: '%env(resolve:ARTACK_GOOGLE_RECAPTCHA_API_KEY)%'
    min_score: 0.5 # default score threshold used by the validator when none is provided

when@dev:
    artack_recaptcha_enterprise:
        enabled: false # disable reCAPTCHA in dev environments

All keys are required. min_score defaults to 0.5 and is used when a constraint does not define its own threshold.

Usage

Render the token field in a Symfony form:

use Artack\RecaptchaEnterpriseBundle\Form\RecaptchaEnterpriseType;
use Artack\RecaptchaEnterpriseBundle\Validator\RecaptchaEnterprise;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;

final class ContactType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('email', EmailType::class)
            ->add('message', TextareaType::class)
            ->add('recaptchaToken', RecaptchaEnterpriseType::class, [
                'action_name' => 'contact',  # sent to Google; also matched when validating
                'script_csp_nonce' => '...' # optional generated nonce to be used in the script tag
                'constraints' => [
                    new RecaptchaEnterprise(
                        minScore: 0.7, # optional
                        actionName: 'contact',
                    ),
                ],
            ]);
    }
}

The provided Twig theme is prepended automatically. When the form submits, the bundle executes grecaptcha.enterprise.execute, fills the hidden field and re-submits the form.

License

This bundle is released under the MIT License.

artack/recaptcha-enterprise-bundle 适用场景与选型建议

artack/recaptcha-enterprise-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 672 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 artack/recaptcha-enterprise-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 artack/recaptcha-enterprise-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 artack/recaptcha-enterprise-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-03