PHPackages                             infernalmedia/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. infernalmedia/laravel-cookie-consent

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

infernalmedia/laravel-cookie-consent
====================================

Cookie consent bottom window for Québec Law 25, forked from statikbe/laravel-cookie-consent

1.0.7(1y ago)06.5k↓13.9%MITPHPPHP ^8.1

Since Sep 13Pushed 1y agoCompare

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

READMEChangelog (8)Dependencies (1)Versions (9)Used By (0)

Laravel cookie consent bottom window
====================================

[](#laravel-cookie-consent-bottom-window)

[![Latest Version on Packagist](https://camo.githubusercontent.com/63e8ec72a0eb16fc8e2c0c11fe53cfa53845d37413ad32ae49084ba3adc0cd72/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e6665726e616c6d656469612f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/infernalmedia/laravel-cookie-consent)[![Total Downloads](https://camo.githubusercontent.com/a3175b39c8424250d243c56062c5bcb53f8b470f44af09d7285e39df70cbd89b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e6665726e616c6d656469612f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/infernalmedia/laravel-cookie-consent)

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)
- [Customizing the dialog texts](#customizing-the-dialog-texts)
    - [Customizing the dialog contents](#customizing-the-dialog-contents)
        - [Publishing](#publishing)
            - [Config](#config)
            - [Translations](#translations)
            - [Views](#views)
- [Configure Google Tag Manager](#configure-google-tag-manager)
- [Security](#security)
- [License](#license)

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

[](#installation)

You can install the package via composer:

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

The package will automatically register itself.

### Cheat sheet

[](#cheat-sheet)

```
php artisan vendor:publish --provider="Infernalmedia\CookieConsent\CookieConsentServiceProvider" --tag="public" --tag="config"
```

Edit `app/Http/Kernel.php`

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

    // ...
}
```

Usage
-----

[](#usage)

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

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

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

1. The first option: include it in your entire project using the kernel:

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

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

    // ...
}
```

2. The second option: include it as a route middleware and add this to any route you want.

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

class Kernel extends HttpKernel
{
    // ...

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

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

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

Customizing the dialog texts
----------------------------

[](#customizing-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="Infernalmedia\CookieConsent\CookieConsentServiceProvider" --tag="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.

### Customizing the dialog contents

[](#customizing-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="Infernalmedia\CookieConsent\CookieConsentServiceProvider" --tag="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.

### Publishing

[](#publishing)

#### Config

[](#config)

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

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

```
return [
    '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' => [],
    '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),
    'facebook_pixel_code' => env('FACEBOOK_PIXEL_CODE', null),
];
```

You can customize some settings that work with your GTM and Facebook Pixel.

#### 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*'];
```

#### Translations

[](#translations)

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

#### Views

[](#views)

```
php artisan vendor:publish --provider="Infernalmedia\CookieConsent\CookieConsentServiceProvider" --tag="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).

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Guillaume Ernst](https://github.com/infernalmedia)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance47

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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 ~97 days

Recently: every ~145 days

Total

7

Last Release

397d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e6b848fc01893e8da4578965df3b420534287587366737940499c8665946438?d=identicon)[guillaume-infernal](/maintainers/guillaume-infernal)

---

Top Contributors

[![kristofser](https://avatars.githubusercontent.com/u/5928907?v=4)](https://github.com/kristofser "kristofser (43 commits)")[![stijnelskens](https://avatars.githubusercontent.com/u/12715277?v=4)](https://github.com/stijnelskens "stijnelskens (32 commits)")[![dduupp](https://avatars.githubusercontent.com/u/10728938?v=4)](https://github.com/dduupp "dduupp (19 commits)")[![guillaume-infernal](https://avatars.githubusercontent.com/u/56695355?v=4)](https://github.com/guillaume-infernal "guillaume-infernal (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![jlalande](https://avatars.githubusercontent.com/u/2721747?v=4)](https://github.com/jlalande "jlalande (1 commits)")[![borjajimnz](https://avatars.githubusercontent.com/u/5682426?v=4)](https://github.com/borjajimnz "borjajimnz (1 commits)")[![Kobo-one](https://avatars.githubusercontent.com/u/11278919?v=4)](https://github.com/Kobo-one "Kobo-one (1 commits)")

---

Tags

laravellaravel-cookie-consentquebecinfernalmedialoi 25

### Embed Badge

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

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

###  Alternatives

[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[yajra/laravel-datatables-editor

Laravel DataTables Editor plugin for Laravel 5.5+.

1186.1M2](/packages/yajra-laravel-datatables-editor)[statikbe/laravel-cookie-consent

Cookie consent modal for EU

213396.7k](/packages/statikbe-laravel-cookie-consent)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)

PHPackages © 2026

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