symkit/faq-bundle

A flexible and modular FAQ (Frequently Asked Questions) management bundle for Symfony applications.

Installs: 39

Dependents: 1

Suggesters: 1

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/symkit/faq-bundle

v0.0.2 2026-02-22 20:27 UTC

This package is auto-updated.

Last update: 2026-02-22 20:28:45 UTC


README

CI Latest Version PHPStan Level 9

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

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: faq controller for accordion toggle behaviour.

Dependencies

License

MIT.