leblanc-simon/eu-cookie-law-bundle
A Symfony bundle for EU cookie law compliance, providing a configurable consent banner and blocking cookies until visitors agree. It helps sites meet GDPR-style requirements with minimal setup and easy integration into existing Twig templates.
First, a reality check that shapes everything else: leblanc-simon/eu-cookie-law-bundle is a Symfony bundle, not a Laravel package. There is no service provider, no config/eu-cookie-law.php, and no Blade directive. A Laravel developer cannot composer require it and expect it to boot. Your realistic options are:
If you go the port route, the first place to look is the bundle's Resources/views/ directory (the notice markup) and its DependencyInjection/Configuration.php (the option names). Those two files tell you 90% of what the bundle actually does: it renders a cookie explanation div with a message, a policy link, and an accept action.
Minimal port skeleton for Laravel:
// config/eu-cookie-law.php
return [
'message' => 'We use cookies to improve your experience.',
'policy_url' => '/privacy',
'accept_label' => 'Accept',
'cookie_name' => 'eu_cookie_consent',
'cookie_lifetime' => 60 * 24 * 365,
];
{{-- resources/views/partials/cookie-notice.blade.php --}}
@unless(request()->cookie(config('eu-cookie-law.cookie_name')))
<div id="eu-cookie-law" role="dialog" aria-live="polite">
<p>{{ config('eu-cookie-law.message') }}
<a href="{{ config('eu-cookie-law.policy_url') }}">Learn more</a></p>
<button onclick="document.cookie='{{ config('eu-cookie-law.cookie_name') }}=1;path=/;max-age={{ config('eu-cookie-law.cookie_lifetime') }}';this.closest('#eu-cookie-law').remove()">
{{ config('eu-cookie-law.accept_label') }}
</button>
</div>
@endunless
Include it once in layouts/app.blade.php. That is your first use case and it covers the bundle's core value: a compliant-looking notice with a link to policy and a persisted acceptance.
Treat it as a UI concern, not a package concern. The bundle only renders a div. The real GDPR work is your cookie inventory, consent storage, and script gating. Use the package (or your port) only for presentation.
Consent storage pattern. Persist acceptance in a first-party cookie with a versioned value (e.g. v1) so you can re-prompt when the policy changes. Read it in a middleware or view composer and share it:
// app/Http/Middleware/ShareCookieConsent.php
public function handle($request, Closure $next)
{
view()->share('cookieConsent', $request->cookie('eu_cookie_consent'));
return $next($request);
}
Gate non-essential scripts. The notice is meaningless if analytics loads before acceptance. Pair the partial with a consent-aware script loader:
@if($cookieConsent)
<script src="{{ mix('js/analytics.js') }}" defer></script>
@endif
Policy route + localization. Point policy_url at a named route (route('privacy')) rather than a hardcoded path, and drive message/accept_label through __() so the notice respects app()->getLocale(). The original bundle ships translations — mirror that with lang/{locale}/cookie.php.
Full-page cache compatibility. If you cache rendered HTML (response cache, Cloudflare), render the notice unconditionally and hide it client-side based on document.cookie. Server-side @unless(cookie) breaks shared caches because the first anonymous response gets cached without the banner.
Testing pattern. One feature test is usually enough:
public function test_notice_is_shown_without_consent_cookie(): void
{
$this->get('/')->assertSee('We use cookies');
}
public function test_notice_is_hidden_with_consent_cookie(): void
{
$this->withCookie('eu_cookie_consent', 'v1')
->get('/')
->assertDontSee('We use cookies');
}
composer require "just works."Resources/public. In Laravel you must copy those into resources/ and run them through Vite/Mix — there is no vendor:publish tag unless you build one.templates/bundles/EuCookieLawBundle/ rather than editing vendor files. In Laravel, the equivalent discipline is a single Blade partial you own.role="dialog"/aria-live and a keyboard-focusable accept button. Add a "reject" path if your legal review requires it — the bundle historically favors implied consent.How can I help you explore Laravel packages today?