Search by

nowo-tech / cookie-consent-bundle

HecFranco

Symfony bundle providing a GDPR cookie consent modal with category toggles and optional consent logging

Package info

github.com/nowo-tech/CookieConsentBundle

Type:symfony-bundle

pkg:composer/nowo-tech/cookie-consent-bundle

Statistics

Installs: 1 774

Dependents: 1

Suggesters: 2

Stars: 0

Open Issues: 0

v1.18.1 2026-10-20 09:15 UTC

README

CI Packagist Version Packagist Downloads License PHP Symfony GitHub stars Coverage

⭐ Found this useful? Install from Packagist · Give it a star on GitHub so more developers can find it.

Symfony bundle that renders a GDPR cookie consent modal with category toggles, optional per-cookie selection, cookie inventory, AJAX form submission, optional consent logging, and configurable Doctrine table prefix. Frontend behavior is implemented in TypeScript and built with Vite (make assets → src/Resources/public/nowo-consent-modal.js).

FrankenPHP Friendly Worker Mode

This bundle is FrankenPHP worker mode friendly, including when the kernel is not reset between requests (reset_kernel false). See the FrankenPHP worker audit.

Demo home page with the two-step consent banner (dark-turquoise theme): Manage preferences, Reject all and Accept all buttons over the page overlay
Consent banner — two-step modal with page overlay
Cookie inventory admin list: name, provider, purpose, category, duration, allowed-by-default badge and row actions, paginated
Admin — cookie inventory per consent profile
Consent profile settings with section tabs, Appearance tab open: colour theme, page overlay, dark mode, transitions and two-step modal options
Admin — profile settings with section tabs

Features

  • GDPR modal — category toggles, optional per-cookie selection, AJAX submit, TypeScript + Vite (nowo-consent-modal.js) and standalone CSS (nowo-cookie-consent.css, CSP-friendly).
  • Themes — ui_theme: bootstrap (default) or tailwind; dual FrankenPHP demos.
  • Cookie inventory — definitions in YAML and/or Doctrine; optional consent logging with configurable table prefix.
  • Admin UI — /cookie-consent-config (profile, behavior, appearance, modals, route targeting) plus CRUD for cookie definitions; built on the UiKit 2.0 page scaffolds (REQ-UI-003): themed once through nowo_ui_kit (layouts, theme slots, tokens) like every Nowo bundle; no CDN assets (TEMPLATES).
  • Preferences bubble — reopen consent after the first choice.
  • Route targeting — render_routes / skip_render_routes; helpers nowo_cookie_consent_should_render() / nowo_cookie_consent_render().
  • Database config — use_database_config so the admin UI can override YAML at runtime; profile copy via nowo_cookie_consent_trans().
  • Cold-start — cooperates with SiteBackupBundle when the schema is not ready yet; the "table exists" probe is memoized per worker (schema_ready_cache_ttl, default 60 s) so public pages skip it after warm-up.
  • CSP nonce — bundle <script> tags carry the request attribute csp_nonce (nowo-tech convention); JS-injected <style> copies the loader script nonce; no inline handlers or inline style attributes.
  • Worker-safe — RequestStack / ManagerRegistry per call; runtime memos cleared on every main request.

Quick start

composer require nowo-tech/cookie-consent-bundle
# config/packages/nowo_cookie_consent.yaml
nowo_cookie_consent:
    doctrine:
        table_prefix: 'app_'   # optional; yields app_dashboard_cookie_log
    use_logger: true
{# templates/base.html.twig — preferred: no kernel sub-request #}
{% if nowo_cookie_consent_should_render() %}
    {{ nowo_cookie_consent_render() }}
{% endif %}

Install public assets:

php bin/console assets:install

Demo

make -C demo up-symfony8
# Bootstrap demo: http://localhost:8014

make -C demo up-symfony8-tailwind
# Tailwind demo: http://localhost:8015
  • demo/symfony8/ — FrankenPHP Symfony 8 app with Bootstrap 5
  • demo/symfony8-tailwind/ — same demo with Tailwind CSS and ui_theme: tailwind

See Demo with FrankenPHP for development vs. production worker mode.

Documentation

Additional documentation

Tests and coverage

Language Lines (approx.) Command
PHP ≥99% line coverage on src/ (run make coverage-check to refresh). See docs/COVERAGE.md. make coverage-check
TypeScript ~94% make test-ts
make test
make coverage-check
make test-ts
make assets
make release-check

PHP coverage target is ≥99% lines (prefer 100%; see Release and docs/COVERAGE.md). TypeScript coverage enforces a minimum of 90% (Vitest thresholds + .scripts/ts-coverage-percent.sh).

License

This bundle is released under the MIT License.