PHPackages                             mmoollllee/laravel-consent-control - 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. [Templating &amp; Views](/categories/templating)
4. /
5. mmoollllee/laravel-consent-control

ActiveLibrary[Templating &amp; Views](/categories/templating)

mmoollllee/laravel-consent-control
==================================

GDPR cookie consent banner and content blocking for Laravel — server-rendered Blade on top of the framework-agnostic consent-control JS runtime.

v0.1.3(1mo ago)0291MITPHPPHP ^8.2CI passing

Since Jul 9Pushed 5d agoCompare

[ Source](https://github.com/mmoollllee/laravel-consent-control)[ Packagist](https://packagist.org/packages/mmoollllee/laravel-consent-control)[ Docs](https://github.com/mmoollllee/laravel-consent-control)[ RSS](/packages/mmoollllee-laravel-consent-control/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (14)Versions (5)Used By (1)

Laravel Consent Control
=======================

[](#laravel-consent-control)

GDPR cookie-consent banner and content blocking for Laravel — server-rendered Blade on top of the framework-agnostic [`consent-control`](https://github.com/mmoollllee/consent-control)JavaScript runtime.

This is the **Laravel layer** of a three-package stack:

PackageRole[`consent-control`](https://github.com/mmoollllee/consent-control) (npm)Framework-agnostic runtime + CSS (plain HTML, WordPress, any framework).**`laravel-consent-control`** (this package)Blade components, config, drivers, translations, server helpers.[`filament-consent-control`](https://github.com/mmoollllee/filament-consent-control)Optional Filament admin UI (settings form + RichEditor iframe plugin).A single config file is all you need — no database, no admin panel required.

Features
--------

[](#features)

- Server-rendered banner (no flash, SEO-friendly) wired by the shared JS runtime
- Configurable consent categories with declarative scripts / inline JS on consent
- Iframe &amp; custom-content blocking via ``
- Conditional rendering via `` (server-side + reactive)
- `config` or `eloquent` driver — store settings in a file or on your own model
- Multilingual (DE/EN, extensible) category labels resolved through `__()`
- Server-side `ConsentControl::granted('analytics')` helper
- Cookie format compatible with the `consent-control` npm package: `consentcontrol=necessary|analytics`

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

[](#requirements)

- PHP 8.2+
- Laravel 11.28+ / 12 / 13

Installation
------------

[](#installation)

```
composer require mmoollllee/laravel-consent-control
```

Publish the config and the runtime assets:

```
php artisan vendor:publish --tag=consent-control-config
php artisan vendor:publish --tag=consent-control-assets
```

Optionally publish the translations to customise them:

```
php artisan vendor:publish --tag=consent-control-translations
```

Frontend usage
--------------

[](#frontend-usage)

Render the banner and load the runtime (once per page, e.g. before ``):

```

```

`` ships a standalone stylesheet by default. If you bundle the CSS yourself (see [Assets](#assets)) disable it with `:standalone-css="false"`.

### Block an iframe until consent

[](#block-an-iframe-until-consent)

```

```

### Block custom content until consent

[](#block-custom-content-until-consent)

```

```

### Conditional content

[](#conditional-content)

```

    Only rendered/visible when analytics consent is granted.

{{-- Or server-side only: --}}
@consent('analytics')

@endconsent
```

### Re-open the banner

[](#re-open-the-banner)

```
Cookie settings
```

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

[](#configuration)

Everything lives in `config/consent-control.php`. Labels and descriptions may be plain strings **or** translation keys — both are resolved through `__()`, so the shipped defaults are multilingual out of the box.

Declare the scripts/JS to run when a category is granted:

```
'analytics' => [
    'label' => 'Analytics',
    'scripts' => [
        ['src' => 'https://www.googletagmanager.com/gtag/js?id=G-XXXX', 'async' => true],
    ],
    'inline_script' => "window.dataLayer = window.dataLayer || [];",
],
```

### Consent versioning

[](#consent-versioning)

Bump `version` whenever your categories or privacy policy change — visitors whose stored version differs are re-prompted (their consent is reset):

```
'version' => env('CONSENT_CONTROL_VERSION', 1), // set null to disable
```

### Block your own scripts

[](#block-your-own-scripts)

Render inert scripts that activate only on consent:

```

    window.dataLayer = window.dataLayer || [];

```

### Eloquent driver (opt-in)

[](#eloquent-driver-opt-in)

Store settings as JSON on one of your own models instead of the config file:

```
CONSENT_CONTROL_DRIVER=eloquent
```

```
// config/consent-control.php
'eloquent' => [
    'model' => App\Models\Setting::class,
    'field' => 'consent_settings',
    'record_id' => 1,
],
```

```
// The model needs a JSON cast:
protected $casts = ['consent_settings' => 'array'];
```

Editing that JSON with a ready-made Filament form is what [`filament-consent-control`](https://github.com/mmoollllee/filament-consent-control) adds.

Frontend assets (choose one)
----------------------------

[](#frontend-assets-choose-one)

Render the banner and the boot component once per page (e.g. before ``):

```

```

**The banner is designed to inherit your site's design** — pick the path that fits your setup:

**A) Bundle it yourself — recommended.** The runtime JS and the overlay CSS become part of your Vite build (no extra requests, full control), and Tailwind styles the banner Blade: it adopts your design tokens (`gray` scale, the toggle uses your `--color-primary`) and your button components (`.btn`, `.btn-primary`, `.btn-secondary`) automatically.

```
// resources/js/app.js
import '../../vendor/mmoollllee/laravel-consent-control/resources/dist/js/consent-control.js';
```

```
/* resources/css/app.css */
@import '../../vendor/mmoollllee/laravel-consent-control/resources/dist/css/consent-message.css';
@source '../../vendor/mmoollllee/laravel-consent-control/resources/views/components/**/*.blade.php';
```

With `:assets="false"` the component emits only the inline `ConsentControl.init(...)` boot config. (Alternatively `npm i consent-control` and import from node\_modules — same runtime.)

**B) Published assets — no build step.** Publish the runtime and let the component load it:

```
php artisan vendor:publish --tag=consent-control-assets   # → public/vendor/consent-control
```

```

```

Tailwind projects still add the `@source` line above and pass `:standalone-css="false"`(the Blade styles the banner). Projects **without** a utility/button system keep the default: a small neutral stylesheet styles banner + overlay buttons and still adopts your brand where it can — the accent reads `--color-primary` / `--bs-primary`, and every `--cc-*` variable can be overridden:

```
#consent-control-banner, .consent-message { --cc-primary: #b91c1c; }
```

**C) Full control.** Publish the views and make them yours — the runtime only needs its selector contract (`#consent-control-banner`, `input[value=]`, `#consent-control--submit(-all)`, `.consent-control--open/--close/--reset`, `.collapsed-only`/`.uncollapsed-only` and the `hide`/`is-collapsed` state classes):

```
php artisan vendor:publish --tag=consent-control-views
```

Reopening the banner
--------------------

[](#reopening-the-banner)

Visitors must be able to change their choice later (GDPR). Place a button with the `consent-control--open` class anywhere — typically on the privacy policy page; the runtime binds every such element on init and reopens the banner with the settings expanded:

```
Cookie-Einstellungen ändern
```

Components &amp; directives
---------------------------

[](#components--directives)

Component / directiveDescription`` / `@consentBanner`Consent banner``Iframe/content with consent overlay``Slot shown only on consent``Consent-gated `` tag`` / `@consentScripts`Runtime + boot config`@consent('analytics') … @endconsent`Server-side conditionalJavaScript events
-----------------

[](#javascript-events)

`window` receives a `consent-updated` event whenever consent changes:

```
window.addEventListener('consent-updated', (e) => console.log(e.detail.consents));
```

License
-------

[](#license)

MIT. See [LICENSE.md](LICENSE.md).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance96

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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 ~2 days

Total

4

Last Release

41d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88283625eedcbfe3f417a3216d2591bb42edb53f361203bb7c46a1d043d70888?d=identicon)[mmoollllee](/maintainers/mmoollllee)

---

Top Contributors

[![mmoollllee](https://avatars.githubusercontent.com/u/26859300?v=4)](https://github.com/mmoollllee "mmoollllee (7 commits)")

---

Tags

laravelbladecookiebannergdprprivacyconsent

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mmoollllee-laravel-consent-control/health.svg)

```
[![Health](https://phpackages.com/badges/mmoollllee-laravel-consent-control/health.svg)](https://phpackages.com/packages/mmoollllee-laravel-consent-control)
```

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818355.4k3](/packages/defstudio-telegraph)[moonshine/moonshine

Laravel administration panel

1.3k268.2k90](/packages/moonshine-moonshine)[spatie/laravel-health

Monitor the health of a Laravel application

88412.7M190](/packages/spatie-laravel-health)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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