fairlane/cookie-consent-bundle
A Symfony bundle for adding cookie consent to your site, giving you a simple way to present consent options and manage cookie permissions. Useful for GDPR-style compliance, though it's a small, low-activity package best reviewed before relying on it in production. Check the source for supported feat...
This is a Symfony bundle, not a Laravel package. There is no service provider, no facade, no config publish tag, and no Laravel auto-discovery. Treat it as source material to port or as a Symfony-side dependency only.
Minimal evaluation steps in a Laravel app:
composer require fairlane/cookie-consent-bundle --dry-run and read the resolved dependency tree. The bundle targets Symfony's framework-bundle and Twig; pulling those into a Laravel project can conflict with the Symfony components Laravel already pins.src/, Resources/config/services.yml (or services.php), Resources/config/routing.*, Resources/views/, and the README. Those files tell you what services, routes, Twig helpers, and templates you would have to re-implement.composer.json. A last release of 2017-11-11 means Symfony 3.x-era APIs; expect incompatibility with Symfony 5/6 and modern PHP.If you are actually maintaining a Symfony app where it belongs: register the bundle in config/bundles.php, import its routing, configure the consent text/categories, and include its Twig template in your base layout. For Laravel, the only sane port path is copying the view/JS behaviour into Blade and replacing the Symfony DI wiring with a Laravel service provider.
Consent-gate middleware. The day-to-day value is not the banner; it is gating non-essential scripts. In Laravel, create middleware that reads a consent cookie (for example cookie_consent containing {"analytics":true,"marketing":false}) and shares the result with views via View::share or a request attribute. Then conditionally render analytics snippets in your layout:
@if (app('cookie-consent')->allows('analytics'))
@include('partials.analytics')
@endif
Blade partial plus vanilla JS. Symfony bundles ship Twig templates; convert the markup to a Blade partial included once in layouts/app.blade.php. Keep the JS cookie-writing logic in a small resources/js/cookie-consent.js file. Prefer SameSite=Lax, an explicit path=/, and a long expiry.
Config bridge. If the bundle exposes configuration (banner text, categories, cookie name, expiry), mirror it in config/cookie-consent.php and register a singleton in AppServiceProvider. Do not try to boot Symfony's config tree inside Laravel.
Granular categories. Model consent as categories (necessary, analytics, marketing) rather than a single accept/reject flag. Store a JSON object in the cookie, version it ("v":1), and re-prompt when your policy version changes. This is the pattern most likely to survive an audit.
Script-loading pattern. For third-party tags, block the <script> tag server-side where possible. If you must defer client-side, use type="text/plain" data-consent="analytics" and swap the type after consent — this is the pattern most cookie-consent libraries use and is straightforward to reimplement.
Testing. Write feature tests that hit a page with and without the consent cookie and assert that the analytics/marketing markup is absent or present. This is the cheapest way to prevent regressions when templates change.
symfony/framework-bundle and conflicting with Laravel's own Symfony component versions; run a dry-run first.$_COOKIE, not Cookie::get(). Pick one mechanism and document it; mixing encrypted and plain cookies is a common source of "consent not detected" bugs.php artisan route:list and php artisan config:clear after wiring config. If you attempt any Symfony bridge, container compilation errors will surface as opaque binding exceptions; isolate each service registration rather than importing the whole bundle.How can I help you explore Laravel packages today?