stijnhau / help-bundle
Admin-editable help pages and FAQs for Symfony apps: ordered sections with anchors, icons and translations, admin-only editing (via stijnhau/moderation-bundle) and optional ready-made pages.
Requires
- php: >=8.4
- doctrine/doctrine-bundle: ^3.4
- doctrine/orm: ^3.8
- psr/clock: ^1.0
- psr/event-dispatcher: ^1.0
- stijnhau/moderation-bundle: ^0.1.1
- symfony/clock: ^8.1
- symfony/config: ^8.1
- symfony/dependency-injection: ^8.1
- symfony/framework-bundle: ^8.1
- symfony/html-sanitizer: ^8.1
- symfony/http-kernel: ^8.1
- symfony/translation-contracts: ^3.5
Requires (Dev)
- phpunit/phpunit: ^13.4
- symfony/browser-kit: ^8.1
- symfony/css-selector: ^8.1
- symfony/event-dispatcher: ^8.1
- symfony/form: ^8.1
- symfony/security-bundle: ^8.1
- symfony/translation: ^8.1
- symfony/twig-bundle: ^8.1
- symfony/yaml: ^8.1
Suggests
- symfony/form: For the ready-made help and help admin pages (stijnhau_help.ui)
- symfony/twig-bundle: For the ready-made help and help admin pages (stijnhau_help.ui)
Provides
None
Conflicts
None
Replaces
None
README
Admin-editable help pages and FAQs for Symfony apps, shared by CityWars,
Crime-Life and F1Manager. A page is ordered sections, each with an anchor
(/help#getting-started), an icon, a title and a rich-text body, plus optional
translations. A section can be an FAQ, where each <h3> is a question. It builds on
stijnhau/moderation-bundle:
only its admins may edit, and every change goes in its audit log.
| Piece | What it does |
|---|---|
Model\AbstractHelpSection |
Doctrine mapped superclass: slug (unique), icon, position, FAQ flag, title, body, translations, updated time. |
Service\HelpAdmin |
create(), update() (from a HelpSectionData), move(), delete(): admins only, with every rule. Bodies are sanitized HTML. |
Query\HelpReader |
Sections in order, by id or anchor; faqItems() splits an FAQ body into questions and answers. |
| Twig UI (optional) | /help and an admin (list, write, edit, reorder, delete) with ui.enabled: true. |
Install
composer require stijnhau/help-bundle
Register and configure stijnhau/moderation-bundle first, then:
#[ORM\Entity] class HelpSection extends AbstractHelpSection {}
stijnhau_help: section_class: App\Entity\HelpSection body_max_length: 50000 sanitizer: ~ # an HtmlSanitizerInterface service id locales: [fr, nl] audit_log: true actions: { created: help.created, updated: help.updated, moved: help.moved, deleted: help.deleted } ui: enabled: false admin_role: ROLE_ADMIN
Then run bin/console make:migration. With the UI enabled, import
@StijnhauHelpBundle/config/routes.php (prefix /help) and routes_admin.php
(prefix /admin/help), both with trailing_slash_on_root: false.
To use your own layout, override templates/bundles/StijnhauHelpBundle/help/layout.html.twig
(keep the help_title and help blocks) and admin/layout.html.twig (keep
help_title and help_admin). Body fields carry data-help-editor.
Errors are HelpExceptions, with keys in the stijnhau_help domain (en/nl/fr included).
A HelpChangedEvent is dispatched for every change.
License
MIT, see LICENSE.