symkit/faq-bundle
Composer 安装命令:
composer require symkit/faq-bundle
包简介
A flexible and modular FAQ (Frequently Asked Questions) management bundle for Symfony applications.
README 文档
README
FAQ Bundle
A flexible and modular FAQ (Frequently Asked Questions) management bundle for Symfony applications. It provides a configurable administration interface (CRUD), public rendering with Stimulus accordion, and automatic position management for FAQ items.
Requirements
- PHP 8.2+
- Symfony 7.0 or 8.0
- Doctrine ORM
- symkit/form-bundle
- symkit/crud-bundle
Installation
1. Require via Composer
composer require symkit/faq-bundle
2. Enable the bundle
Register the bundle in config/bundles.php:
return [ // ... Symkit\FaqBundle\SymkitFaqBundle::class => ['all' => true], ];
3. Update database schema
php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
Configuration
All features can be enabled or disabled via the bundle configuration. Create or edit config/packages/symkit_faq.yaml:
symkit_faq: enabled: true admin: enabled: true route_prefix: /admin public: enabled: true route_prefix: /faq entity: # Override with your own classes if you extend the default entities faq_class: Symkit\FaqBundle\Entity\Faq faq_repository_class: Symkit\FaqBundle\Repository\FaqRepository faq_item_class: Symkit\FaqBundle\Entity\FaqItem faq_item_repository_class: Symkit\FaqBundle\Repository\FaqItemRepository doctrine: enabled: true twig: enabled: true asset_mapper: enabled: true
If you use custom entity or repository classes (e.g. extending the defaults), configure them here and ensure your Doctrine mapping covers the same tables or your overrides.
Routes
Import the bundle routes in your application config/routes.yaml.
Configurable prefixes (recommended; uses admin.route_prefix and public.route_prefix from config):
symkit_faq: resource: 'symkit_faq.route_loader::loadRoutes' type: service
Fixed paths (/admin, /faq):
symkit_faq: resource: '@SymkitFaqBundle/config/routes.yaml'
This registers:
- Admin:
/admin/faqs(list, create, edit, delete),/admin/faqs/{faqId}/items/create,/admin/faq-items/{id}/edit,/admin/faq-items/{id}/delete - Public:
/faq/{code}(show FAQ by code)
You can wrap the import with a custom prefix if you need to change the URL prefix.
Translations
The bundle provides XLIFF translations in SymkitFaqBundle (and validators for constraint messages) in English and French. Translations are auto-discovered from the bundle translations/ directory.
To override or add locales, place your files in your app’s translations/ directory with the same domain names (SymkitFaqBundle.*.xlf, validators.*.xlf).
Usage
Displaying a FAQ in Twig
Render a FAQ block by code (e.g. from a controller that loaded the entity):
{{ include('@SymkitFaq/faq/components/_faq.html.twig', {
faq: faq_entity
}) }}
Admin interface
The admin CRUD is available at /admin/faqs (or your configured prefix). It uses symkit/crud-bundle for lists, forms, and actions.
Customizing templates
Override bundle templates under your project:
templates/bundles/SymkitFaqBundle/faq/
Copy the relevant Twig files from vendor/symkit/faq-bundle/templates/faq/ and edit them.
Assets and Stimulus
The bundle registers its Stimulus controller via AssetMapper. Ensure your app uses AssetMapper and that the faq controller is loaded (e.g. in your importmap.php and Stimulus app registration). The accordion uses data-controller="faq" and data-action="faq#toggle".
Components
- Entities:
Faq(group of questions),FaqItem(question/answer with position). - Stimulus:
faqcontroller for accordion toggle behaviour.
Dependencies
- doctrine/doctrine-bundle — ORM integration
- doctrine/orm — Entity persistence
- symfony/validator — Validation
- symkit/form-bundle — FormSectionType, SlugType, form theme
- symkit/crud-bundle — CRUD and list UI
License
MIT.
symkit/faq-bundle 适用场景与选型建议
symkit/faq-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 60 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 symkit/faq-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 symkit/faq-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 60
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 29
- 依赖项目数: 1
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-22