devrabiul/laravel-cookie-consent
GDPR-compliant cookie consent for Laravel with one-click install. Lightweight, no frontend deps, responsive banner with dark mode, RTL/i18n, and granular category controls (necessary/analytics/marketing). Fully customizable colors, text, and layout via config.
loadGoogleAnalytics) via config, allowing seamless integration with third-party scripts.styles()/scripts()) and config updates. No database migrations or model alterations.loadFacebookPixel) must be implemented manually. Risk: Inconsistent behavior if not properly scoped. Mitigation: Provide template examples and validation for action names.loadGoogleAnalytics to include consent checks.bar-inline) conflict with existing UI designs? Action: Test with A/B variations.cookie_consent events.GET /api/cookie-consent).bar-inline layout) with necessary cookies enabled by default.COOKIE_CONSENT_ENABLED) to toggle during testing.laravel/framework constraint in composer.json.Session::cookie()) for fallback.composer require devrabiul/laravel-cookie-consent
php artisan vendor:publish --provider="Devrabiul\CookieConsent\CookieConsentServiceProvider"
config/cookie-consent.php for:
.env)./privacy-policy).{!! CookieConsent::styles() !!} to <head>.{!! CookieConsent::scripts() !!} before </body>.resources/views/vendor/cookie-consent/).loadGoogleAnalytics) in resources/js/cookie-consent.js.COOKIE_CONSENT_ENABLED in .env and Blade inclusion.loadGoogleAnalytics) are defined globally.config/cookie-consent.php matches app settings.consent_log table) if auditing is required..example.com).| Failure | Impact | Mitigation |
|---|---|---|
| Banner blocks critical JS | Broken UX (e.g., analytics scripts) | Use disable_page_interaction=false |
| Cookie consent not saved | Non-compliance | Add middleware to validate consent on routes |
| Custom JS action fails | Third-party scripts load incorrectly | Implement fallback logic in loadGoogleAnalytics |
| Config misalignment | Wrong cookies enabled/disabled | Use .env overrides for critical settings |
| RTL/dark mode conflicts | Visual regressions | Test with real devices/browsers |
How can I help you explore Laravel packages today?