PHPackages                             jostkleigrewe/cookie-consent-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. jostkleigrewe/cookie-consent-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

jostkleigrewe/cookie-consent-bundle
===================================

Symfony 8 bundle for GDPR/DSGVO cookie consent with Google Consent Mode v2, Twig components, Stimulus.js, and AssetMapper. Supports cookie, Doctrine, or combined storage. Includes YouTube, Vimeo, Google Maps embed components.

v0.5.1(2mo ago)168↓100%MITPHPPHP &gt;=8.4CI failing

Since Jan 23Pushed 2mo agoCompare

[ Source](https://github.com/jostkleigrewe/cookie-consent-bundle)[ Packagist](https://packagist.org/packages/jostkleigrewe/cookie-consent-bundle)[ Docs](https://github.com/jostkleigrewe/cookie-consent-bundle)[ GitHub Sponsors](https://github.com/sponsors/jostkleigrewe)[ RSS](/packages/jostkleigrewe-cookie-consent-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (20)Versions (9)Used By (0)

Symfony Cookie Consent Bundle – GDPR/DSGVO Cookie Banner with Google Consent Mode v2
====================================================================================

[](#symfony-cookie-consent-bundle--gdprdsgvo-cookie-banner-with-google-consent-mode-v2)

[![Packagist Version](https://camo.githubusercontent.com/95204ba4fe2f2e09efcd780c00742f878471129a3d8f0cb5b2f6a527eae157e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f73746b6c656967726577652f636f6f6b69652d636f6e73656e742d62756e646c65)](https://packagist.org/packages/jostkleigrewe/cookie-consent-bundle)[![Packagist Downloads](https://camo.githubusercontent.com/ef54de1a5a1cbc4507f3430ffd629046d4fee4fedcc4d657d92362b600757799/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f73746b6c656967726577652f636f6f6b69652d636f6e73656e742d62756e646c65)](https://packagist.org/packages/jostkleigrewe/cookie-consent-bundle)[![PHP Version](https://camo.githubusercontent.com/62761511eff816c253648e35ae5c7067f971fb7929145d1f91296aace3fb73d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a6f73746b6c656967726577652f636f6f6b69652d636f6e73656e742d62756e646c65)](https://packagist.org/packages/jostkleigrewe/cookie-consent-bundle)[![CI](https://github.com/jostkleigrewe/cookie-consent-bundle/actions/workflows/ci.yml/badge.svg)](https://github.com/jostkleigrewe/cookie-consent-bundle/actions/workflows/ci.yml)[![License](https://camo.githubusercontent.com/d5f8318a47998ac5de5c0908cc8f0005557d480b10b1b131e7156f5560cf625a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a6f73746b6c656967726577652f636f6f6b69652d636f6e73656e742d62756e646c65)](LICENSE)

> **A modern Symfony 8 bundle for GDPR/DSGVO-compliant cookie consent management.** Includes Google Consent Mode v2 support, Twig components, Stimulus.js integration, and AssetMapper compatibility. Perfect for cookie banners, consent modals, and privacy-compliant websites.

**[🇩🇪 Deutsche Version](README.de.md)** · **[📦 Packagist](https://packagist.org/packages/jostkleigrewe/cookie-consent-bundle)** · **[📖 Documentation](docs/getting-started.md)**

Why this bundle?
----------------

[](#why-this-bundle)

- ✅ Symfony-native consent handling with Twig, Stimulus, and AssetMapper
- ✅ Vendor-level toggles + Consent Mode v2 for modern ad stacks
- ✅ Session-safe by design: prevents unwanted session cookies

Screenshot
----------

[](#screenshot)

[![Cookie Consent Modal](docs/assets/cookie-consent-modal.png)](docs/assets/cookie-consent-modal.png)

Features
--------

[](#features)

- 🎯 **GDPR &amp; DSGVO Compliant** – Cookie consent with policy versioning and audit logging
- 📊 **Google Consent Mode v2** – Built-in GA4, Google Ads, and gtag integration
- 🎨 **Multiple Themes** – Tabler (light/dark), Bootstrap 5, or custom templates
- ⚡ **Stimulus.js &amp; Turbo** – Hotwire-compatible, no full page reload needed
- 🗂️ **AssetMapper Ready** – No Webpack/Encore required, works out of the box
- 🧭 **Flexible Storage** – Cookie-only, Doctrine ORM, or combined (hybrid)
- 🧩 **Vendor-Level Consent** – Optional per-vendor toggles (Google Ads, Meta, etc.)
- 🛡️ **Session Protection** – Prevents session cookies without explicit consent
- 🎬 **Embed Components** – YouTube, Vimeo, Google Maps, Spotify, Instagram, TikTok with consent gates
- 🧪 **Twig Helpers** – `cookie_consent_has()`, `cookie_consent_modal()`, and more
- 📝 **Audit Logging** – Track consent changes with optional database persistence

Requirements
------------

[](#requirements)

- PHP 8.4+
- Symfony 8.0+
- Twig Bundle, Security Bundle, Stimulus Bundle
- Doctrine ORM + DoctrineBundle (optional, only for `storage: doctrine|both`)

Compatibility
-------------

[](#compatibility)

Bundle VersionPHPSymfony0.4.x8.4+8.0+0.3.x8.3+7.1+0.2.x8.2+7.0+Quick Start
-----------

[](#quick-start)

### 1. Install

[](#1-install)

```
composer require jostkleigrewe/cookie-consent-bundle
```

### 2. Register routes

[](#2-register-routes)

Create `config/routes/cookie_consent.yaml`:

```
cookie_consent:
    resource: '@CookieConsentBundle/config/routes.php'
```

This registers the `/_cookie-consent` endpoint required for consent updates.

### 3. Configure assets

[](#3-configure-assets)

**Option A: Twig helper (CSP-compatible, recommended)**

```
{# templates/base.html.twig - in  #}
{{ cookie_consent_styles() }}
```

This renders a standard `` tag, fully compatible with strict Content-Security-Policy headers.

**Option B: JavaScript import**

```
// assets/app.js
import '@jostkleigrewe/cookie-consent-bundle/styles/cookie_consent.css';
```

> **Note:** With strict CSP (`style-src 'self'`), bundlers may convert CSS imports to `data:` URLs, which can be blocked. Use Option A if you encounter CSP issues.

```
// assets/controllers.json
{
  "controllers": {
    "@jostkleigrewe/cookie-consent-bundle": {
      "cookie-consent": { "enabled": true, "fetch": "eager" }
    }
  }
}
```

### 4. Render the modal

[](#4-render-the-modal)

```
{# templates/base.html.twig #}
{{ cookie_consent_modal() }}
```

### 5. Gate content by consent

[](#5-gate-content-by-consent)

```
{% if cookie_consent_has('analytics') %}

{% endif %}
```

Or use lazy loading:

```

```

Configuration
-------------

[](#configuration)

Create `config/packages/cookie_consent.yaml`:

```
cookie_consent:
  policy_version: '1'
  storage: cookie  # cookie, doctrine, or both

  categories:
    necessary:
      label: Necessary
      required: true
      default: true
    analytics:
      label: Analytics
      default: false
    marketing:
      label: Marketing
      default: false
      vendors:
        google_ads:
          label: Google Ads
          default: false

  ui:
    template: '@CookieConsent/styles/tabler/modal.html.twig'
    position: center
    privacy_url: '/privacy'
    reload_on_change: false

  logging:
    retention_days: null

  google_consent_mode:
    enabled: false
```

### Storage Modes

[](#storage-modes)

ModeDescriptionUse Case`cookie`Browser cookie only (default)Simple sites, no DB required`doctrine`Database only via Doctrine ORMServer-side consent verification`both`Cookie + Database (cookie as primary, DB as backup)Full audit trail + fast accessIf `storage` is set to `doctrine` or `both`, generate migrations in your app (bundle ships entities, not migrations). This requires Doctrine ORM:

```
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
```

Increment `policy_version` when changing categories to require re-consent.

If `logging.retention_days` is set, run the cleanup command regularly:

```
bin/console cookie-consent:cleanup
```

Documentation
-------------

[](#documentation)

- **[Getting Started](docs/getting-started.md)** - Installation, assets, first steps
- **[Configuration](docs/configuration.md)** - All options, templates, Twig helpers
- **[Advanced](docs/advanced.md)** - Storage backends, session enforcement, logging, events
- **[Integration](docs/integration.md)** - Components, helpers, attributes, data attributes, events
- **[Changelog](CHANGELOG.md)** - Releases and notable changes
- **[Contributing](CONTRIBUTING.md)** - Development workflow and guidelines

Embed Components
----------------

[](#embed-components)

Gate third-party content with built-in components:

```

```

Alternative:

```
{{ component('CookieConsentYoutubeEmbed', {
  video_id: 'dQw4w9WgXcQ',
  category: 'marketing',
  vendor: 'youtube'
}) }}
```

Available: YouTube, Vimeo, Google Maps, Spotify, Twitter/X, Instagram, TikTok, and more.

Integration Overview
--------------------

[](#integration-overview)

See **[Integration](docs/integration.md)** for Twig components, helpers, data attributes, controller attributes, and events.

Troubleshooting
---------------

[](#troubleshooting)

### Modal doesn't appear

[](#modal-doesnt-appear)

- Ensure `{{ cookie_consent_modal() }}` is in your base template
- Check browser console for JavaScript errors
- Verify Stimulus controller is loaded: `@jostkleigrewe/cookie-consent-bundle/cookie-consent`

### Assets not loading (404)

[](#assets-not-loading-404)

- Run `bin/console cache:clear`
- Check AssetMapper paths: `bin/console debug:asset-map | grep cookie`
- Ensure `assets/app.js` imports the CSS

### Session cookie created before consent

[](#session-cookie-created-before-consent)

- Check `enforcement.require_consent_for_session` is `true`
- Add routes to `stateless_routes` if they should work without session
- Verify `#[ConsentStateless]` attribute on stateless controllers

### Doctrine storage not working

[](#doctrine-storage-not-working)

- Run migrations: `bin/console doctrine:migrations:diff && bin/console doctrine:migrations:migrate`
- Check `storage: doctrine` or `storage: both` is set
- Verify `doctrine/orm` and `doctrine/doctrine-bundle` are installed

### Google Consent Mode not updating

[](#google-consent-mode-not-updating)

- Ensure `google_consent_mode.enabled: true`
- Check `gtag` is loaded before the consent modal
- Verify category mapping matches your categories

### Tabler variant styling issues (missing border-radius, labels below checkbox)

[](#tabler-variant-styling-issues-missing-border-radius-labels-below-checkbox)

- **Cause:** Tabler loads after bundle CSS and overrides `.modal-content` and `form-switch` styles
- **Solution:** Update to latest bundle version (&gt;= 0.4.2) which includes Tabler-specific fixes
- **Manual fix:** Add to your CSS with higher specificity:

```
.cookie-consent-modal.cookie-consent-variant-tabler .modal-content {
    border: 0;
    border-radius: var(--cc-radius, 18px);
    box-shadow: var(--cc-shadow, 0 24px 60px rgba(15, 23, 42, 0.25));
}
.cookie-consent-variant-tabler .cookie-consent-toggle.form-switch {
    display: block;
    padding-left: 2.5rem;
}
.cookie-consent-variant-tabler .cookie-consent-toggle.form-switch .form-check-input {
    float: left;
    margin-left: -2.5rem;
}
```

Contributing
------------

[](#contributing)

```
composer install
composer ci
```

License
-------

[](#license)

MIT - see [LICENSE](LICENSE).

Resources
---------

[](#resources)

- [Packagist](https://packagist.org/packages/jostkleigrewe/cookie-consent-bundle)
- [GitHub Repository](https://github.com/jostkleigrewe/cookie-consent-bundle)
- [Documentation](docs/getting-started.md)
- [Report Issues](https://github.com/jostkleigrewe/cookie-consent-bundle/issues)
- [Changelog](CHANGELOG.md)

Keywords
--------

[](#keywords)

Symfony cookie consent, GDPR cookie banner, DSGVO cookie modal, Google Consent Mode v2, Symfony 8 bundle, cookie management, consent management platform, CMP, Twig cookie component, Stimulus.js cookie, AssetMapper, Doctrine consent storage, YouTube embed consent, privacy compliance, e-privacy.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance83

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

8

Last Release

84d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b83fea9bc07f393871b8ccf857e47844c4986bf87a9db5a584c65f20427c605b?d=identicon)[jostkleigrewe](/maintainers/jostkleigrewe)

---

Top Contributors

[![jostkleigrewe](https://avatars.githubusercontent.com/u/5504283?v=4)](https://github.com/jostkleigrewe "jostkleigrewe (30 commits)")

---

Tags

symfonybundletwigsymfony-uxdoctrinecookieSymfony Bundlegoogle-analyticssymfony8gdprprivacycookie-consentconsent-managementaudit-logturbohotwireasset-mapperconsentdsgvocookie-bannerga4stimulusgtagcookie-modalcmpconsent-modegoogle-consent-modeDatenschutztwig-componente-privacyyoutube-embedvimeo-embedgoogle-maps-embed

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jostkleigrewe-cookie-consent-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/jostkleigrewe-cookie-consent-bundle/health.svg)](https://phpackages.com/packages/jostkleigrewe-cookie-consent-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
