承接 bartacus/bartacus-bundle 相关项目开发

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

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

bartacus/bartacus-bundle

Composer 安装命令:

composer require bartacus/bartacus-bundle

包简介

Integrates the Symfony full-stack framework into TYPO3

README 文档

README

Welcome to the BartacusBundle - the Symfony bundle + TYPO3 extension which integrates the Symfony framework fully into your TYPO3 v14.3.* CMS.

What Bartacus Bundle does

BartacusBundle transforms TYPO3 into a Symfony-first environment, allowing developers to build TYPO3 extensions and websites using modern Symfony patterns while retaining the powerful content management capabilities of TYPO3.

Full Symfony Stack in TYPO3

It initializes the project's Symfony kernel at the very beginning of the PHP process. This properly injects the full Symfony stack into TYPO3 and allows the project source code to be written as if it were a standard Symfony application.

Event-driven Configuration

Bartacus uses a ConfigLoader to hook into TYPO3's configuration lifecycle (AdditionalConfiguration, RequestMiddlewares, Extbase Persistence) via Symfony Events. This allows developers to extend or modify TYPO3's configuration using standard Symfony event listeners.

Symfony Controllers as Content Elements

You can use Symfony controllers as TYPO3 content elements by simply adding the #[ContentElement()] attribute to your controller methods.

  • Automatically generates TypoScript configuration.
  • Converts TYPO3 content object data into Symfony request/models.
  • Handles NotFoundHttpException by triggering TYPO3's native 404 error handling.

Integrated Symfony Routing

The bundle allows you to define standard Symfony routes that coexist with TYPO3 page requests. When a Symfony route is hit:

  1. It intercepts the request early in the TYPO3 middleware stack.
  2. It fakes a TYPO3 request context to ensure TYPO3 configurations (like TypoScript) are loaded.
  3. It handles the request via the Symfony Kernel and returns the response to the browser.

Service Interoperability

BartacusBundle provides deep integration between the Symfony Container and TYPO3's GeneralUtility:

  • Symfony Services in TYPO3: Services tagged with bartacus.make_instance are automatically available via GeneralUtility::makeInstance(). This is achieved by injecting a ServiceLocator directly into TYPO3's singletonInstances.
  • TYPO3 Services in Symfony: The ServiceBridge provides a clean API to access TYPO3's global state (Backend/Frontend User, LanguageService, etc.) and core components are registered as Symfony services for easy injection.

Unified Request Localization

Normalizes the locale between TYPO3 and Symfony to ensure consistent language handling. The base locale is extracted with the following priority:

  1. TYPO3 site language object from request attributes.
  2. Symfony router _locale parameter.
  3. TYPO3 site default language object.

It ensures the locale format is consistent (e.g., de_AT for Symfony requests, while the Symfony router uses the URL-friendly de-at).

Static Routes and Optimized Middleware

The bundle overrides the loading order of TYPO3 core middlewares and introduces a custom StaticRouteMiddleware. This ensures that static routes (like /robots.txt) are handled early via the StaticRouteEvent, avoiding unnecessary database-heavy operations. It even includes a default subscriber to generate SEO-friendly robots.txt files automatically.

Enhanced Error Handling

Overrides both Symfony and TYPO3 error/exception handlers to provide a unified, detail-rich Symfony error page, greatly improving the debugging experience within the TYPO3 context.

Advanced Twig and Template Integration

Bartacus provides a powerful bridging layer between Twig and TYPO3:

  • TWIGTEMPLATE Content Object: A new TYPO3 Content Object that allows you to render Twig templates directly from TypoScript. It supports variable passing (via nested cObjects), stdWrap, and even rendering into TYPO3's header/footer data blocks.
  • bartacus_cobject Twig Function: Allows you to execute and render any TYPO3 Content Object (like RECORDS, CONTENT, or IMAGE) directly from your Twig templates, with full support for data and table context.
  • controller(...) Twig Function: Enables you to execute and render Symfony controllers directly from your Twig templates, seamlessly mixing Symfony logic with your template rendering.

How it Works

1. Early Kernel Bootstrap

The bundle requires patching TYPO3's entry points (public/index.php and vendor/bin/typo3) to initialize the SymfonyBootstrap class. This class boots the Symfony Kernel before TYPO3 starts, making the Symfony Container available throughout the entire TYPO3 lifecycle.

2. Service Container Hooking

During the bundle's boot process, it manipulates GeneralUtility's internal state. It injects a ServiceLocator into GeneralUtility::singletonInstances and updates the finalClassNameCache. This "infects" TYPO3's service resolution, allowing Symfony to fulfill requests for instances that it manages.

3. Middleware Interception

The bundle registers several middlewares in the TYPO3 Frontend stack:

  • Static Route Middleware: Intercepts requests for static paths and dispatches a StaticRouteEvent.
  • Route Resolver: Checks for Symfony route matches before TYPO3 tries to resolve a page.
  • Content Element Renderer: Handles the execution of controllers for content elements during the page rendering process.

4. Data Bridging (ServiceBridge)

The ServiceBridge acts as a central hub for TYPO3 integration. It allows you to safely access global state and provides helper methods for common TYPO3 tasks (like getting the current backend user or rendering a content object) without relying on global variables.

5. Event-driven Configuration (ConfigLoader)

The ConfigLoader acts as a bridge during the TYPO3 configuration phase. It dispatches Symfony events that allow the bundle (and other Symfony bundles) to inject configuration like custom middlewares or Extbase persistence classes directly into TYPO3.

6. Template Bridging

The template namespace provides a bi-directional bridge for rendering. It allows TYPO3 to use Twig as a rendering engine via the TWIGTEMPLATE cObject, and allows Twig templates to pull in TYPO3 content via the bartacus_cobject function.

Patches

The bundle relies on several patches to achieve this deep integration:

  • allow_extbase_access_in_cli_mode.patch: Enables TYPO3 Extbase usage in CLI by faking a request object.
  • enable_symfony_serviceBridge.patch: Injects the custom service bridge into GeneralUtility.
  • proper_symfony_kernel_bootstrap_cli.patch: Patches vendor/bin/typo3 for early kernel boot.
  • proper_symfony_kernel_bootstrap_web.patch: Patches public/index.php for early kernel boot.

bartacus/bartacus-bundle 适用场景与选型建议

bartacus/bartacus-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47.54k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2015 年 05 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「container」 「framework」 「symfony」 「twig」 「service container」 「services」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 47.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 17
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 8
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2015-05-12