Download the PHP package statikbe/laravel-cookie-consent without Composer
On this page you can find all versions of the php package statikbe/laravel-cookie-consent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download statikbe/laravel-cookie-consent
More information about statikbe/laravel-cookie-consent
Files in statikbe/laravel-cookie-consent
Package laravel-cookie-consent
Short Description Cookie consent modal for EU
License MIT
Homepage https://github.com/statikbe/laravel-cookie-consent
Informations about the package laravel-cookie-consent
Laravel cookie consent modal
Cookie banner and preferences modal for Laravel. Visitors choose which cookie categories they accept; Google Tag Manager reads the resulting cookie to decide which tags fire. Based on spatie/laravel-cookie-consent with added per-category consent.
Requirements
| Laravel | PHP |
|---|---|
| 10–13 | 8.0+ |
Upgrading
See upgrading.md.
Table of contents
- Installation
- Configuration
- Filament Integration
- Customisation
- Google Tag Manager
- Security
- License
Installation
1. Install via Composer
The package registers itself automatically.
2. Register the middleware
Laravel 11 and later — in bootstrap/app.php:
Or as a named alias:
Laravel 10 and earlier — in app/Http/Kernel.php:
Or as a named middleware applied to specific routes:
The middleware injects the cookie consent snippet into every HTML response before the closing </body> tag.
3. Publish the assets
4. Include the stylesheet (default theme only)
Add this to your base template. Skip this step if you are using the Filament theme — see Filament Integration.
Configuration
Publish the config file:
config/cookie-consent.php:
Hiding the banner on specific pages
Wildcards use Laravel's Str::is() matching.
Hiding the banner on error pages
Filament Integration
If your project uses Filament, you can render the cookie banner using Filament components instead of the default styled theme.
1. Enable the Filament theme
This will render the cookie popup using Filament components:
The default theme looks like this for comparison:
2. Configure Tailwind to scan the package views
Tailwind v4 — in your main CSS file:
Tailwind v3 — in tailwind.config.js:
3. Filament styles outside the panel
If you display the cookie banner on pages that are not inside a Filament panel, include Filament's CSS and JS in those page templates.
4. Cookie settings nav item
When the Filament theme is active, the package registers a "Cookie settings" link in the Filament user menu. The position is controlled by filament-nav-item-render-hook, which defaults to after the profile menu item.
To change the position, set a different render hook value:
To remove the nav item entirely:
Customisation
Translations
Publish the language files:
Files land in lang/vendor/cookie-consent/{locale}/texts.php. To add a new locale, copy the en directory to the target locale and translate the strings.
Views
Publish the view files:
Files land in resources/views/vendor/cookie-consent.
To let visitors re-open the preferences modal (e.g. from your footer next to the cookie policy link):
Google Tag Manager
Set up GTM to read the consent cookie and control which tags fire. Full setup instructions: docs/google-tag-manager.md.
Security
If you discover a security issue, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.