PHPackages                             elhebert/laravel-croustillon - 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. elhebert/laravel-croustillon

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

elhebert/laravel-croustillon
============================

A package to help you manage your cookie banner and cookie policy with ease

0.0.5(7y ago)954MITPHPPHP ^7.1.3

Since Nov 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Elhebert/laravel-croustillon)[ Packagist](https://packagist.org/packages/elhebert/laravel-croustillon)[ RSS](/packages/elhebert-laravel-croustillon/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (6)Used By (0)

Laravel Croustillon
===================

[](#laravel-croustillon)

A package to help you manage your cookie banner and cookie policy with ease.

> Documentation is still a work in progress.

Why `laravel-croustillon`?
--------------------------

[](#why-laravel-croustillon)

I'm glad you asked. During the develoment of this packages I used `Cookie` to namespace everything which quickly made it hard to dicerne the Laravel Cookie classes and the Cookie from my package.

I start thinking about names to use and thought of names like Donuts, Cake, Waffle or Biscuit. I discussed this with a colleague ([@meduzen](https://github.com/meduzen)) and I joked about using `Croustillon` because it would make everything awesome.

Croustillon is a (french) Belgian word. For the non belgian people out here, Google Translate tells me it's called a donut in english, but I'm sceptical.

So here's a picture:

[![croustillon](https://camo.githubusercontent.com/0405ec7302430542e56f252fec6322ca7b7f51a72081e1b1bff5c36e902035da/687474703a2f2f7777772e6c6573666f6f646965732e636f6d2f5f726563697065696d6167652f39383333392f626569676e65742d63726f757374696c6c6f6e2e6a7067)](https://camo.githubusercontent.com/0405ec7302430542e56f252fec6322ca7b7f51a72081e1b1bff5c36e902035da/687474703a2f2f7777772e6c6573666f6f646965732e636f6d2f5f726563697065696d6167652f39383333392f626569676e65742d63726f757374696c6c6f6e2e6a7067)

Disclaimer
----------

[](#disclaimer)

I'm not a lawyer, so everything here should be taken with a grain of salt, especially the legal documents.

Therefor I decline all responsability for any legal issues you might encounter by using this package without checking the legal documents with a lawyer.

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

[](#installation)

```
composer require elhebert/laravel-croustillon
```

This package uses [auto-discovery](https://laravel.com/docs/packages#package-discovery), so you don't have to do anything.

You can publish the config-file with:

```
php artisan vendor:publish --provider="Elhebert\Croustillon\CroustillonServiceProvider" --tag="croustillon-config"
```

You can publish the language-file with:

```
php artisan vendor:publish --provider="Elhebert\Croustillon\CroustillonServiceProvider" --tag="croustillon-translations"
```

You can publish the view-files with:

```
php artisan vendor:publish --provider="Elhebert\Croustillon\CroustillonServiceProvider" --tag="croustillon-views"
```

You can add a cookie banner to all responses of your app by registering `Elhebert\Croustillon\Http\Middlewares\AddCookieBanner::class` in the http kernel.

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

...

protected $middlewareGroups = [
   'web' => [
       ...
       \Elhebert\Croustillon\Http\Middlewares\AddCookieBanner::class,
   ],
```

Alternatively you can apply the middleware on the route or route group level.

```
// in a routes file

Route::get('my-page', 'MyController')->middleware(Elhebert\Croustillon\Http\Middlewares\AddCookieBanner::class);
```

Usage
-----

[](#usage)

This package allows you to define a cookie policy. A cookie policy determines which cookies are used within your website and generate a corresponding banner and legal page.

By default every Laravel application has 2 cookies set, the `laravel_session` cookie and the `XSRF-TOKEN` cookie. Using a new Laravel application as example, here what you can expect:

```
// in a policy

...
    ->addCookie(Xsrf::class)
    ->addCookie(Session::class)
...
```

### Creating a cookie

[](#creating-a-cookie)

As we all know website are not limited to use the default cookies and might use new ones for all kind of reasons. Which is why you can create custom cookies to add to a policy.

A cookie is compose of a name, a description, a duration, a purpose, a source and a category.

```
namespace Elhebert\Croustillon\Cookies;

use Elhebert\Croustillon\Categories\Mandatory;

class Xsrf extends Cookie
{
    public $name = 'XSRF-TOKEN';

    public $category = Mandatory::class;

    public $source = 'Laravel';

    public $duration = '2 hours';

    public $purpose = 'security';
}
```

This package comes with pre-defined categories from which you can choose from:

```
Elhebert\Croustillon\Categories\Mandatory::class
Elhebert\Croustillon\Categories\Preferences::class
Elhebert\Croustillon\Categories\Analytics::class
Elhebert\Croustillon\Categories\Social::class
Elhebert\Croustillon\Categories\Retargetting::class
```

Depending on which cookies you added to your policy, it'll impact the cookie banner and the legal page. The banner will add checkboxes for each categories of cookies (to offer fully granularity to the visitor) and the legal page will add the cookies and corresponding categories to the list of cookies.

If you need to customize the different variables you can use the corresponding functions instead of the variable:

```
public function duration(): string
{
    return config('session.lifetime') . ' minutes';
}

public function purpose(): string
{
    return trans('croustillon::cookies.purposes.security');
}
```

### Creatiing a policy

[](#creatiing-a-policy)

Once you have all your cookies, you need to create a new policy:

```
namespace App\Service\Croustillon\Policies;

use Elhebert\Croustillon\Policies\Basic;
use App\Service\Croustillon\Cookie\MyCustomCookie;

class MyCustomPolicy extends Basic
{
    public function configure()
    {
        parent::configure();

        $this
            ->addCookie(MyCustomCookie::class);
    }
}
```

Don't forget to update the `policy` key of the config file to the class of your policy (in this case it would be `App\Service\Croustillon\Policies\MyCustomPolicy`).

### Customising the cookie banner and the legal page

[](#customising-the-cookie-banner-and-the-legal-page)

This package comes with a default cookie banner and legal page that you can (and should) customize, to do so you need to publish the package views:

```
php artisan vendor:publish --provider="Elhebert\Croustillon\CroustillonServiceProvider" --tag="croustillon-views"
```

#### Cookie banner

[](#cookie-banner)

The banner will be in `resources/views/vendor/croustillon/banner.blade.php`. By default it's generating the checkboxes for every cookie categories present in your policy. The mandatory category will be checked and disable (because it's *mandatory*).

It also comes bundle with a controller and a route, so you don't need to worry about creating them in your application.

The default route is `/croustillon`.

#### Cookie legal page

[](#cookie-legal-page)

The legal page can be found in `resources/views/vendor/croustillon/policy.blade.php`. The main content of that page is already done, but you still should update it to suit your need and your website.

The default route for this page is `/croustillon/policy`.

Customization
-------------

[](#customization)

This package come with opinions. Like routes, copy and views.

Everything can be customize.

### Routes

[](#routes)

The prefix can be customize in the config file but should you need complete control on the routes you can disable the ones from this package to create your own.

The routes you need to create are:

- For the cookie banner form:

    - Verb: `POST`
    - Action: `\Elhebert\Croustillon\Http\Controllers\CookiesController` (it has an `__invoke` method, so you don't need to reference a method).
- For the cookie policy legal page:

    - Verb: `GET`
    - Action: `\Elhebert\Croustillon\Http\Controllers\CookiePolicyController` (it has an `__invoke` method, so you don't need to reference a method).

### Translations

[](#translations)

You can overwrite the default translations by publishing the language files.

### Views

[](#views)

You can overwrite the default views by publishing the view files.

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

[](#contributing)

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

License
-------

[](#license)

This project and the Laravel framework are open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Total

5

Last Release

2715d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/efd06548e5d3377c053337fb7983451b07e50ceecd0a73a318bfde96c53a1754?d=identicon)[Elhebert](/maintainers/Elhebert)

---

Tags

hacktoberfestlaravelcookiegdprcroustillon

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/elhebert-laravel-croustillon/health.svg)

```
[![Health](https://phpackages.com/badges/elhebert-laravel-croustillon/health.svg)](https://phpackages.com/packages/elhebert-laravel-croustillon)
```

###  Alternatives

[yajra/laravel-datatables-oracle

jQuery DataTables API for Laravel

4.9k33.8M339](/packages/yajra-laravel-datatables-oracle)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[statikbe/laravel-cookie-consent

Cookie consent modal for EU

213396.7k](/packages/statikbe-laravel-cookie-consent)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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