PHPackages                             statikbe/laravel-cookie-consent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. statikbe/laravel-cookie-consent

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

statikbe/laravel-cookie-consent
===============================

Cookie consent modal for EU

1.12.0(2mo ago)213396.7k—4.4%27[1 issues](https://github.com/statikbe/laravel-cookie-consent/issues)[3 PRs](https://github.com/statikbe/laravel-cookie-consent/pulls)MITPHPPHP ^8.0CI failing

Since Feb 3Pushed 1mo ago8 watchersCompare

[ Source](https://github.com/statikbe/laravel-cookie-consent)[ Packagist](https://packagist.org/packages/statikbe/laravel-cookie-consent)[ Docs](https://github.com/statikbe/laravel-cookie-consent)[ RSS](/packages/statikbe-laravel-cookie-consent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (61)Used By (0)

[![Card of Laravel Cookie consent](docs/img/card.png)](docs/img/card.png)

Laravel cookie consent modal
============================

[](#laravel-cookie-consent-modal)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1eb0a368df213765a20936d36b34b1a1bcc00e987298904470f429e5a7006933/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73746174696b62652f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/statikbe/llaravel-cookie-consent)[![Total Downloads](https://camo.githubusercontent.com/2b4b69ce2cf77631a81206971a3432037fcd842376d178b45243ef2ce15600d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746174696b62652f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/statikbe/laravel-cookie-consent)

[![Modal cookie consent](docs/img/modal.png?raw=true "Modal for Cookie consent")](docs/img/modal.png?raw=true)

[![Preferences Modal](docs/img/preferences.png?raw=true "Preferences for cookies")](docs/img/preferences.png?raw=true)

The package includes a script &amp; styling for a cookie banner and a modal where the visitor can select his/her cookie preferences.

This package is mainly based on the one from spatie:

With the only exception that you can choose which cookies you enable. This only works when Google Tag Manager is correctly configured (some regex config based on the value set in the cookie).

- [Upgrading](upgrading.md)
- [Installation](#installation)
- [Usage](#usage)
- [Customising the dialog texts](#customising-the-dialog-texts)
    - [Customising the dialog contents](#customising-the-dialog-contents)
    - [Publishing](#publishing)
        - [Config](#config)
        - [Skip cookie consent on error pages](#skip-cookie-consent-on-error-pages)
        - [Translations](#translations)
        - [Views](#views)
- [Configure Google Tag Manager](#configure-google-tag-manager)
- [Security](#security)
- [License](#license)

Upgrading
---------

[](#upgrading)

You can find our upgrading guides [here](upgrading.md).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require statikbe/laravel-cookie-consent
```

The package will automatically register itself.

First of all **you need to** publish the javascript and css files:

```
php artisan vendor:publish --provider="Statikbe\CookieConsent\CookieConsentServiceProvider" --tag="cookie-public"
```

When using the default theme, make sure to include the css/cookie-consent.css into your base.blade.php or any other base template you use.

```

```

If you want to use the filament theme, make sure to source the blade files in your tailwind config

tailwind v4:

```
/* point to the actual vendor location */
@source 'vendor/statikbe/laravel-cookie-consent/resources/**/*.blade.php';
```

tailwind v3 and below:

```
export default {
    content: [
        'vendor/statikbe/laravel-cookie-consent/resources/**/*.blade.php';
    ]
}
```

The javascript file is included in the cookie snippet and will be added at the end of your body.

If you want to show the filament themed cookie banner outside of your filament panel, also make sure that you include the filament styles and scripts in your templates.

Usage
-----

[](#usage)

Instead of including a snippet in your view, we will automatically add it. This is done using middleware using two methods:

**For Laravel 11.x and newer**

```
// bootstrap/app.php

->withMiddleware(function (Middleware $middleware) {
    ...
    $middleware->web(append: [
        ...
        \Statikbe\CookieConsent\CookieConsentMiddleware::class,
    ]);

// OR AS AN ALIAS

    $middleware->alias([
        ...
        'cookie-consent' => \Statikbe\CookieConsent\CookieConsentMiddleware::class,
    ]);
})
```

**For Laravel 10.x and earlier**

```
// app/Http/Kernel.php

class Kernel extends HttpKernel
{
    protected $middleware = [
        // ...
        \Statikbe\CookieConsent\CookieConsentMiddleware::class,
    ];

     protected $routeMiddleware = [
        // ...
        'cookie-consent' => \Statikbe\CookieConsent\CookieConsentMiddleware::class,
    ];

// routes/web.php
Route::group([
    'middleware' => ['cookie-consent']
], function(){
    // ...
});
}
```

This will add `cookieConsent::index` to the content of your response right before the closing body tag.

Customising the dialog texts
----------------------------

[](#customising-the-dialog-texts)

If you want to modify the text shown in the dialog you can publish the lang-files with this command:

```
php artisan vendor:publish --provider="Statikbe\CookieConsent\CookieConsentServiceProvider" --tag="cookie-lang"
```

This will publish this file to `resources/lang/vendor/cookieConsent/en/texts.php`.

```
return [
    'alert_title' => 'Deze website gebruikt cookies',
    'setting_analytics' => 'Analytische cookies',
];
```

If you want to translate the values to, for example, English, just copy that file over to `resources/lang/vendor/cookieConsent/fr/texts.php` and fill in the English translations.

### Customising the dialog contents

[](#customising-the-dialog-contents)

If you need full control over the contents of the dialog. You can publish the views of the package:

```
php artisan vendor:publish --provider="Statikbe\CookieConsent\CookieConsentServiceProvider" --tag="cookie-views"
```

This will copy the `index` view file over to `resources/views/vendor/cookieConsent`.

The `cookie-settings` view file is just a snippet you need to place somewhere onto your page. Most preferably in the footer next to the url of your cookie policy.

```
@lang('cookie-consent::texts.alert_settings')
```

This gives your visitor the opportunity to change the settings again.

### Customising the theme

[](#customising-the-theme)

By default, the cookie popup will look like this:

[![screenshot of default theme](./assets/screenshot-default.png)](./assets/screenshot-default.png)

If you are however working on a project that is using filament, you can opt to use filament componets to render your cookie popup.

To do this, configure the theme to `filament`

```
'theme' => 'filament'

```

This will render the cookie popup like so:

[![screenshot of filament theme](./assets/screenshot-filament.png)](./assets/screenshot-filament.png)

### Publishing

[](#publishing)

#### Config

[](#config)

```
php artisan vendor:publish --provider="Statikbe\CookieConsent\CookieConsentServiceProvider" --tag="cookie-config"
```

This is the contents of the published config-file: This will read the policy urls from your env.

```
return [
    /**
     * Theme to use for the cookie consent popup.
     * Available options: 'default', 'filament'.
     */
    'theme' => 'default',
    /**
     * Filament render hook where the package will
     * register a navigation item to show the cookie
     * settings modal.
     * Set to null to disable this.
     */
    'filament-nav-item-render-hook' => PanelsRenderHook::USER_MENU_PROFILE_AFTER,
    'disable_filament_nav_hook' => false,
    'cookie_key' => '__cookie_consent',
    'cookie_value_analytics' => '2',
    'cookie_value_marketing' => '3',
    'cookie_value_both' => 'true',
    'cookie_value_none' => 'false',
    'cookie_expiration_days' => '365',
    'gtm_event' => 'pageview',
    'ignored_paths' => [],
    /**
     * Skip cookie consent on error responses (4xx and 5xx status codes).
     * Set to true if you want to disable cookie banner on error pages.
     */
    'skip_on_error_responses' => false,
    'cookie_secure' => env('COOKIE_CONSENT_SECURE', false),
    'policy_url_en' => env('COOKIE_POLICY_URL_EN', null),
    'policy_url_fr' => env('COOKIE_POLICY_URL_FR', null),
    'policy_url_nl' => env('COOKIE_POLICY_URL_NL', null),
];
```

You can customize some settings that work with your GTM.

#### Don't show modal on cookie policy page or other pages

[](#dont-show-modal-on-cookie-policy-page-or-other-pages)

If you don't want the modal to be shown on certain pages you can add the relative url to the ignored paths setting. This also accepts wildcards (see the Laravel `Str::is()` [helper](https://laravel.com/docs/9.x/helpers#method-str-is)).

```
'ignored_paths => ['/en/cookie-policy', '/api/documentation*'];

```

#### Skip cookie consent on error pages

[](#skip-cookie-consent-on-error-pages)

By default, the cookie consent banner is shown on error pages (404, 500, etc.). If you want to disable the banner on error responses, you can set this option to `true`:

```
'skip_on_error_responses' => true,

```

#### Translations

[](#translations)

```
php artisan vendor:publish --provider="Statikbe\CookieConsent\CookieConsentServiceProvider" --tag="cookie-lang"
```

#### Views

[](#views)

```
php artisan vendor:publish --provider="Statikbe\CookieConsent\CookieConsentServiceProvider" --tag="cookie-views"
```

Configure Google Tag Manager
----------------------------

[](#configure-google-tag-manager)

All the steps to configure your Google Tag Manager can be found [here](docs/google-tag-manager.md).

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

65

—

FairBetter than 99% of packages

Maintenance89

Actively maintained with recent releases

Popularity54

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Recently: every ~28 days

Total

52

Last Release

61d ago

PHP version history (2 changes)1.2.9PHP ^7.0|^8.0

1.5.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1250437446b84017407f7f1900194b1e1c93fcf34b332ba382fb77f69b251cb6?d=identicon)[statikbe](/maintainers/statikbe)

---

Top Contributors

[![kristofser](https://avatars.githubusercontent.com/u/5928907?v=4)](https://github.com/kristofser "kristofser (87 commits)")[![sevbesau](https://avatars.githubusercontent.com/u/16073039?v=4)](https://github.com/sevbesau "sevbesau (42 commits)")[![stijnelskens](https://avatars.githubusercontent.com/u/12715277?v=4)](https://github.com/stijnelskens "stijnelskens (32 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (28 commits)")[![dduupp](https://avatars.githubusercontent.com/u/10728938?v=4)](https://github.com/dduupp "dduupp (19 commits)")[![carolineboeykens](https://avatars.githubusercontent.com/u/42932673?v=4)](https://github.com/carolineboeykens "carolineboeykens (13 commits)")[![sten](https://avatars.githubusercontent.com/u/180665?v=4)](https://github.com/sten "sten (4 commits)")[![patimio66](https://avatars.githubusercontent.com/u/78798236?v=4)](https://github.com/patimio66 "patimio66 (3 commits)")[![javiersanzsanchez](https://avatars.githubusercontent.com/u/16131716?v=4)](https://github.com/javiersanzsanchez "javiersanzsanchez (1 commits)")[![borjajimnz](https://avatars.githubusercontent.com/u/5682426?v=4)](https://github.com/borjajimnz "borjajimnz (1 commits)")[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (1 commits)")[![janhenckens](https://avatars.githubusercontent.com/u/755428?v=4)](https://github.com/janhenckens "janhenckens (1 commits)")[![AurelDemiri](https://avatars.githubusercontent.com/u/30560661?v=4)](https://github.com/AurelDemiri "AurelDemiri (1 commits)")[![Kobo-one](https://avatars.githubusercontent.com/u/11278919?v=4)](https://github.com/Kobo-one "Kobo-one (1 commits)")[![Mejans](https://avatars.githubusercontent.com/u/61360811?v=4)](https://github.com/Mejans "Mejans (1 commits)")

---

Tags

laravelcookieGoogle Tag Managerfilamentgdprprivacyconsentcookie-banner

### Embed Badge

![Health badge](/badges/statikbe-laravel-cookie-consent/health.svg)

```
[![Health](https://phpackages.com/badges/statikbe-laravel-cookie-consent/health.svg)](https://phpackages.com/packages/statikbe-laravel-cookie-consent)
```

###  Alternatives

[devrabiul/laravel-cookie-consent

A GDPR-compliant cookie consent solution for Laravel applications with fully customizable cookie banners, granular consent control, and enterprise-grade compliance features.

17633.8k1](/packages/devrabiul-laravel-cookie-consent)[martin-schenk/laravel-cookie-consent

GDPR-compliant cookie consent system with minimal dependencies for Laravel 11 and 12

101.3k](/packages/martin-schenk-laravel-cookie-consent)[codingfreaks/cf-cookiemanager

Manage cookies, scripts, and GDPR compliance on your Typo3 website with CodingFreaks Typo3 Cookie Manager. Customize cookie banners, streamline workflow, and enhance user experience. Ensure GDPR compliance and take control of cookie management with our Typo3 cookie management extension. Visit the official Typo3 Documentation page to learn more.

1625.8k](/packages/codingfreaks-cf-cookiemanager)[marcogermani87/filament-cookie-consent

Easy cookie consent integrations for Filament

1917.0k](/packages/marcogermani87-filament-cookie-consent)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
