zencule / cookie-banner
A modern, customizable cookie consent banner for Laravel and Statamic applications
Installs: 32
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:statamic-addon
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0
- statamic/cms: ^4.0|^5.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.0
README
A modern, customizable cookie consent banner for Laravel and Statamic applications. Built with Alpine.js and plain CSS (no Tailwind required).
Features
- 🎨 Modern, responsive design with plain CSS (no Tailwind required)
- ⚡ Smooth animations with Alpine.js
- 📊 Google Analytics integration
- 🔒 GDPR-compliant with essential/all cookies options
- 🎯 Works with both Laravel and Statamic
- ⚙️ Fully customizable through config
Installation
You can install the package via composer:
composer require zencule/cookie-banner
CSS
The package includes a plain CSS file for styling. To use the default styles, import or copy cookie-banner.css
from the package's resources/
directory into your project and include it in your main CSS or HTML:
<link rel="stylesheet" href="/path/to/cookie-banner.css">
Or, if using a bundler:
import 'cookie-banner/resources/cookie-banner.css';
Laravel
The package will automatically register its service provider.
Publish the configuration file:
php artisan vendor:publish --tag=cookie-banner
Statamic
The package will automatically register as a Statamic addon.
Publish the configuration file:
php artisan vendor:publish --tag=cookie-banner
Usage
Laravel
Add the cookie banner to your layout file:
@include('cookie-banner::banner')
Statamic
Add the cookie banner to your layout file:
{{ zencule:cookie-banner }}
Configuration
Configure the banner in config/cookie-banner.php
:
return [ 'privacy_policy_url' => env('COOKIE_BANNER_PRIVACY_URL', '/privacy-policy'), 'analytics_id' => env('COOKIE_BANNER_ANALYTICS_ID', ''), 'messages' => [ 'banner_text' => 'We use cookies to improve your experience...', 'essential_button' => 'Essential Only', 'accept_button' => 'Accept All', 'more_info' => 'More Information', ], ];
Customization
Styling
The banner uses plain CSS classes by default. You can customize the appearance by:
- Publishing the views:
php artisan vendor:publish --tag=cookie-banner
-
Modifying the templates in:
- Laravel:
resources/views/vendor/cookie-banner/blade/banner.blade.php
- Statamic:
resources/views/vendor/cookie-banner/antlers/banner.antlers.html
- Laravel:
-
Editing the CSS file:
- Copy or import
resources/cookie-banner.css
and modify it as needed for your branding.
- Copy or import
Analytics
By default, the package supports Google Analytics. Set your Analytics ID in your .env
file:
COOKIE_BANNER_ANALYTICS_ID=G-XXXXXXXXXX
The script will only load after the user accepts all cookies.
Requirements
- PHP 8.1 or higher
- Laravel 10.0 or higher
- Statamic 4.0 or higher (for Statamic integration)
- Alpine.js
Contributing
Please see CONTRIBUTING.md for details.
Security
If you discover any security-related issues, please email security@zencule.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.