symkit/builder-bundle 问题修复 & 功能扩展

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

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

symkit/builder-bundle

Composer 安装命令:

composer require symkit/builder-bundle

包简介

Visual Content Builder Bundle

README 文档

README

CI Latest Version PHPStan Level 9

A powerful, strategy-based block building system for Symfony applications. This bundle provides a flexible architecture for managing, editing, and rendering dynamic content blocks.

Features

  • Strategy Pattern Architecture: Extensible system where each block type is handled by a dedicated strategy.
  • Dual-View Rendering:
    • Editor: Complex, interactive templates (Twig + Stimulus + LiveComponents) for the admin interface.
    • Frontend: Lightweight, clean HTML structures defined in the database for performance and separation of concerns.
  • Markdown Import: Intelligent service to convert Markdown content into structured blocks, delegating logic to strategies.
  • Live Components Integration: Built-in support for Symfony UX Live Components for a rich editing experience.
  • 13 Built-in Block Types: paragraph, image, quote, table, list, code, infobox, cta, howto, separator, video, faq_block, and snippet.
  • 183 Tailwind CSS Snippets: Pre-built UI components across 32 categories, optionally loadable via sync command.

Documentation

Installation

  1. Require the bundle:

    composer require symkit/builder-bundle
  2. Enable the bundle (if not auto-enabled):

    // config/bundles.php
    return [
        // ...
        Symkit\BuilderBundle\SymkitBuilderBundle::class => ['all' => true],
    ];

Configuration

All features are enabled by default. You can override entity classes and toggle features in config/packages/symkit_builder.yaml:

symkit_builder:
    admin:
        enabled: true
        route_prefix: admin   # URL prefix for admin routes (default: admin)
    doctrine:
        enabled: true
        entity:
            block_class: Symkit\BuilderBundle\Entity\Block
            block_repository_class: Symkit\BuilderBundle\Repository\BlockRepository
            block_category_class: Symkit\BuilderBundle\Entity\BlockCategory
            block_category_repository_class: Symkit\BuilderBundle\Repository\BlockCategoryRepository
    twig:
        enabled: true
    assets:
        enabled: true
    command:
        enabled: true
    live_component:
        enabled: true

Routes

Include the bundle admin routes in your app (e.g. config/routes.yaml):

symkit_builder:
    resource: '@SymkitBuilderBundle/Resources/config/routing.yaml'
    prefix: '%symkit_builder.admin.route_prefix%'

This registers routes such as admin_block_list, admin_block_create, admin_block_edit, admin_block_category_*. Change route_prefix in config to alter the URL prefix (e.g. /back-office/blocks).

Dependencies

Ensure you have the following bundles enabled and configured:

  • Symfony\UX\LiveComponent\LiveComponentBundle
  • Symfony\UX\TwigComponent\TwigComponentBundle
  • Symfony\UX\StimulusBundle\StimulusBundle

Usage

1. Rendering Blocks

Two Twig functions are available for rendering blocks in your frontend templates.

Render a single block (accepts an array):

{# templates/page/show.html.twig #}

{% for block in page.content %}
    {{ symkit_render_block(block) }}
{% endfor %}

Render all blocks at once (accepts a JSON string or an array):

{{ symkit_render_content_blocks(page.content) }}

Or manually via the service:

use Symkit\BuilderBundle\Contract\BlockRendererInterface;

public function show(BlockRendererInterface $renderer, array $blocks)
{
    // Render a single block
    $html = $renderer->renderBlock($block);

    // Or render all blocks at once
    $html = $renderer->renderBlocks($blocks);
}

2. Synchronizing Blocks

Blocks are defined within the BlockSynchronizer service. To ensure your database is updated with the latest block definitions, run the synchronization command:

php bin/console builder:sync-blocks

To also include the 183 Tailwind CSS snippets:

php bin/console builder:sync-blocks --snippets

This command uses an idempotent "upsert" logic, updating existing blocks by their code and creating new ones as needed.

3. Built-in Block Types

The bundle ships with 13 core block types across 6 categories:

Category Block Type Description
text paragraph Rich text content (visual / HTML modes)
text quote Blockquote with optional author
media image Image via media manager
media video Embedded video (YouTube, etc.)
layout table Data table with optional header row
layout separator Horizontal rule (solid, dashed, dotted)
content list Ordered or unordered list
content code Syntax-highlighted code block
design infobox Highlighted info box (info, success, warning, error)
marketing cta Call-to-action with button and URL
marketing howto Step-by-step guide
marketing faq_block FAQ section (requires symkit/faq-bundle)
(snippets) snippet Pre-built Tailwind CSS component

4. Adding a New Block Type

To add a block type without custom logic, register it in BlockSynchronizer and use AbstractBlockStrategy as the default fallback. See How to Add a New Block Type for the full guide.

For complex blocks (e.g., fetching data, processing URLs), create a Strategy:

  1. Create a class implementing BlockStrategyInterface (or extending AbstractBlockStrategy).
  2. Implement supports(), prepareData(), render().
  3. Implement supportsNode() and createFromNode() for Markdown import support.
namespace App\Block\Strategy;

use Symkit\BuilderBundle\Render\Strategy\AbstractBlockStrategy;

class MyCustomBlockStrategy extends AbstractBlockStrategy
{
    public function supports(array $block): bool
    {
        return $block['type'] === 'my_custom_block';
    }

    // ... implement other methods
}

The service will be automatically tagged and used by the BlockRenderer.

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-22