Download the PHP package mmoollllee/laravel-consent-control without Composer
On this page you can find all versions of the php package mmoollllee/laravel-consent-control. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mmoollllee/laravel-consent-control
More information about mmoollllee/laravel-consent-control
Files in mmoollllee/laravel-consent-control
Package laravel-consent-control
Short Description GDPR cookie consent banner and content blocking for Laravel — server-rendered Blade on top of the framework-agnostic consent-control JS runtime.
License MIT
Homepage https://github.com/mmoollllee/laravel-consent-control
Informations about the package 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
JavaScript runtime.
This is the Laravel layer of a three-package stack:
| Package | Role |
|---|---|
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 |
Optional Filament admin UI (settings form + RichEditor iframe plugin). |
A single config file is all you need — no database, no admin panel required.
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 & custom-content blocking via
<x-consent-control-message> - Conditional rendering via
<x-consent-control-gate>(server-side + reactive) configoreloquentdriver — 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-controlnpm package:consentcontrol=necessary|analytics
Requirements
- PHP 8.2+
- Laravel 11.28+ / 12 / 13
Installation
Publish the config and the runtime assets:
Optionally publish the translations to customise them:
Frontend usage
Render the banner and load the runtime (once per page, e.g. before </body>):
<x-consent-control-scripts /> ships a standalone stylesheet by default. If you bundle
the CSS yourself (see Assets) disable it with :standalone-css="false".
Block an iframe until consent
Block custom content until consent
Conditional content
Re-open the banner
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:
Consent versioning
Bump version whenever your categories or privacy policy change — visitors whose stored
version differs are re-prompted (their consent is reset):
Block your own scripts
Render inert scripts that activate only on consent:
Eloquent driver (opt-in)
Store settings as JSON on one of your own models instead of the config file:
Editing that JSON with a ready-made Filament form is what
filament-consent-control adds.
Frontend assets (choose one)
Render the banner and the boot component once per page (e.g. before </body>):
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.
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:
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:
C) Full control. Publish the views and make them yours — the runtime only needs its
selector contract (#consent-control-banner, input[value=<category>],
#consent-control--submit(-all), .consent-control--open/--close/--reset,
.collapsed-only/.uncollapsed-only and the hide/is-collapsed state classes):
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:
Opening moves the keyboard focus into the banner, saving moves it back to the button.
Withdrawing consent and the reset button
Scripts a category has loaded keep running after a visitor withdraws it, so the runtime reloads the page then, and after the reset button ("delete all cookies"). The reset button deletes every cookie and localStorage entry the page can reach — keep what your app needs:
Components & directives
| Component / directive | Description |
|---|---|
<x-consent-control-banner /> / @consentBanner |
Consent banner |
<x-consent-control-message consent="…" src="…" /> |
Iframe/content with consent overlay |
<x-consent-control-gate consent="…"> |
Slot shown only on consent |
<x-consent-control-script consent="…" src="…" /> |
Consent-gated <script> tag |
<x-consent-control-scripts /> / @consentScripts |
Runtime + boot config |
@consent('analytics') … @endconsent |
Server-side conditional |
JavaScript events
window receives a consent-updated event whenever consent changes:
License
MIT. See LICENSE.md.
All versions of laravel-consent-control with dependencies
illuminate/contracts Version ^11.28|^12.0|^13.0
illuminate/support Version ^11.28|^12.0|^13.0
spatie/laravel-package-tools Version ^1.16