klehm/content-blocks-kit
Composer 安装命令:
composer require klehm/content-blocks-kit
包简介
Ready-to-use block types for ContentBlocks (Text, Title, Image, Tabs).
README 文档
README
Ready-to-use block types for klehm/content-blocks.
The kit is self-contained: no Tailwind/Bootstrap, no LiipImagine, no icon
library. Every block renders neutral cb-kit-* markup styled by a single
shipped stylesheet, so it drops into any host regardless of its CSS setup.
Included blocks
| Type | What it is |
|---|---|
title |
Heading with visual size, semantic tag, and palette text color |
text |
Plain paragraph text with palette text color |
rich_text |
WYSIWYG (TinyMCE) rich text |
image |
Image with size preset / custom size, fit, align, link, caption, rounded corners |
gallery |
Image grid or slider (arrows) with columns, fit, rounded corners |
button |
Call-to-action button (variants, sizes, alignment) |
card |
Image/title/text/button tiles as a grid or list |
list |
Bulleted / checkmark / numbered list |
icon |
A single icon from the shipped icon set |
alert |
Info / success / warning / error callout |
divider |
Horizontal rule (style + color) |
accordion |
Collapsible panels (native <details>, zero JS) |
table |
Columns + rows data table |
embed |
Responsive YouTube / Vimeo embed |
breadcrumb |
Breadcrumb trail |
html_raw |
Raw HTML escape hatch (disabled by default — opt in) |
tabs |
Tabbed panels |
Installation
composer require klehm/content-blocks klehm/content-blocks-kit
The blocks are auto-registered via Symfony autoconfiguration — no config needed to get all of them.
Front stylesheet (required)
Kit blocks render with neutral cb-kit-* classes styled by a stylesheet the kit
serves at a public route. Include it once in your front layout (it also flows
into the builder preview):
<link rel="stylesheet" href="{{ path('content_blocks_kit_asset_css') }}">
Retheme by overriding the --cb-kit-* custom properties (or the classes) in
your own stylesheet loaded after it.
Stimulus controllers
Enable the kit's controllers in your host assets/controllers.json under the
@klehm/content-blocks-kit package: cb-tinymce (rich text) and cb-gallery
(gallery slider).
Configuring blocks
Each block exposes four levers under content_blocks_kit.blocks.<type>:
| Key | Purpose |
|---|---|
enabled |
false un-registers the block's service — it never reaches the picker. |
options |
Block-level knobs (e.g. max_columns), merged over the block's coded ones. |
choices |
Per-field allow-list restricting/reordering a ChoiceType field. |
defaults |
Per-field overrides of a block's initial data (what a new block starts with). |
# config/packages/content_blocks_kit.yaml content_blocks_kit: blocks: tabs: { enabled: false } # drop a block entirely html_raw: { enabled: true } # opt into a default-disabled block gallery: options: { max_columns: 4 } # cap the column choices button: choices: variant: [primary, secondary] # only these two, in this order, in the picker size: [md, lg] defaults: variant: secondary # new buttons start as "secondary" align: center title: defaults: { size: h1 } # new titles default to h1 size
Notes:
- Blocks omitted from config are enabled with their coded defaults — except
html_raw, which is disabled by default: it renders unescaped markup ({{ html|raw }}), so it trusts its editors and must be opted in explicitly. choicesvalues not offered by the block are ignored; an empty or all-invalid list falls back to the full set (the select is never empty). Restricting the picker does not invalidate content already stored with a now-hidden value — validation still accepts the block's full coded set.defaultsonly apply to fields the block declares; unknown keys are ignored.
Colors
All color fields — icon and divider colors, the title and text blocks'
text color, and the rich-text (TinyMCE) swatches — draw from the one core
palette declared in content_blocks.palette (see the main package README). Add a
named color there once and it appears everywhere:
# config/packages/content_blocks.yaml content_blocks: palette: - { label: 'Brand', color: '#eb0540' }
Discovering the surface
List every block with its options, choice fields (default marked *) and data
defaults — read straight from the code, so it never goes stale:
bin/console content-blocks-kit:blocks # all blocks bin/console content-blocks-kit:blocks button # one block
Overriding block templates
Drop a file at the matching relative path under templates/bundles/ContentBlocksKitBundle/ to override any template shipped by this kit — e.g. templates/bundles/ContentBlocksKitBundle/block/image/view.html.twig overrides the image view.
Requires
klehm/content-blocks-kit >= 0.1.0-alpha.4for overrides to take priority. Earlier versions manually registered the vendortemplates/path under@ContentBlocksKit, which shadowed the host'stemplates/bundles/ContentBlocksKitBundle/directory.
File uploads
ImageBlock uses the main package's upload brick (ImageUploadType, the
/_content-blocks/upload endpoint and FileStorageInterface — all in
klehm/content-blocks now). Enable it via the bundle config:
# config/packages/content_blocks.yaml content_blocks: upload: dir: '%kernel.project_dir%/public/uploads/content-blocks' public_prefix: '/uploads/content-blocks'
Documentation & contributing
Full documentation and development setup live in the monorepo: github.com/klehm/content-blocks-project
License
MIT
klehm/content-blocks-kit 适用场景与选型建议
klehm/content-blocks-kit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「blocks」 「symfony-bundle」 「page-builder」 「content-blocks」 「symfony-ux」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 klehm/content-blocks-kit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 klehm/content-blocks-kit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 klehm/content-blocks-kit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Blocks for NetCommons Plugin
A block that displays featured content - large image, title, description and link.
Flexslider slideshow content block for Silverstripe Elemental
A block to display a list of links to child pages, or pages in current level
Collection of useful and reusable SilverStripe Elemental stylings properties
The bundle for easy using json-rpc api on your project
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 45
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-29