PHPackages                             markohs/protectionbanner - 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. [Security](/categories/security)
4. /
5. markohs/protectionbanner

ActiveLibrary[Security](/categories/security)

markohs/protectionbanner
========================

Customizable Laravel Middleware to comply with EU cookie lawls and protect adult websites from child access forcing the client to accept conditions before any cookie or anything is sent.

v0.1.4(6y ago)113MITPHP

Since Feb 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Markohs/ProtectionBanner)[ Packagist](https://packagist.org/packages/markohs/protectionbanner)[ Docs](https://github.com/markohs/protectionbanner)[ RSS](/packages/markohs-protectionbanner/feed)WikiDiscussions master Synced yesterday

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

ProtectionBanner
================

[](#protectionbanner)

[![Build Status](https://camo.githubusercontent.com/593666099d9763d9046343380af9455633e6d255c7ae26c0be88e3ec635a1198/68747470733a2f2f7472617669732d63692e6f72672f4d61726b6f68732f50726f74656374696f6e42616e6e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Markohs/ProtectionBanner)[![Latest Version on Packagist](https://camo.githubusercontent.com/33b69f9fcb4d3418f18ee42b57d6b2f7c2bf2beb26108e4e1e0525200a148aef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61726b6f68732f70726f74656374696f6e62616e6e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/markohs/protectionbanner)[![Total Downloads](https://camo.githubusercontent.com/4bd89c3e78a76313c407907d8632957765a4179f90466aa55621b837508bafab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61726b6f68732f70726f74656374696f6e62616e6e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/markohs/protectionbanner)[![StyleCI](https://camo.githubusercontent.com/9f69b2bf5a79b54b43e71bbaae078c17fb902675f2558359ee13b187e4fdae9d/68747470733a2f2f7374796c6563692e696f2f7265706f732f3233383438303836352f736869656c64)](https://styleci.io/repos/238480865)[![](https://camo.githubusercontent.com/25b3e6d0d42c98de74a98cbb4d149a1c09020cf6d1361993b72d7d5b8ffed363/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](http://makeapullrequest.com)[![](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)

Customizable Laravel Middleware to comply with EU Cookie Law (GDPR) and also protect adult websites from child access.

This software goes the hard way to be sure you comply the law:

- All HTTP requests are captured and a full page banner is shown to the user. This page doesn't use cookies at all, no session is mantained.
- Once the user accepts the condition, a cookie is sent, and user is redirected to the original intended page. All future interactions, proceed as usual. Original GET parameters are passed on to the original request.
- It detects crawlers so SEO , opengraph, reddit, twitter... remains unaffected. They are unaffected by this package.
- There is a whitelist mechanism so you can exclude certain URL from your website from this behaviour too.

Take a look at [contributing.md](contributing.md) to see a to do list.

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

[](#installation)

Via Composer

```
$ composer require markohs/protectionbanner
```

Publish the default config file and default view:

```
$  php artisan vendor:publish --tag=ProtectionBanner

```

You can now edit default settings in `config/protectionbanner.php` and use `/resources/views/vendor/protectionbanner/banner.blade.php` as a boilerplate for your banner.

Usage
-----

[](#usage)

You can use any of the following methods to force the banner:

You can either force HTTPS in a single route in for example `routes/web.php`:

```
Route::get('/','StaticPageController@getRoot')->middleware('protectionbanner');
```

You can also use the automatic MiddlewareGroup register mechanism in `config/protectionbanner.php`:

```
    'autoregister' => ['web']
```

Or you can add the Middleware manually as usual in `app/Http/Kernel.php` in the MiddlewareGroups you require:

```
...
'web' => [
    \App\Http\Middleware\EncryptCookies::class,
...
    \Markohs\ProtectionBanner\Middleware\ProtectionBannerMiddleware::class,
...

    \Illuminate\Routing\Middleware\SubstituteBindings::class,
],
..
```

### Cawler and SEO

[](#cawler-and-seo)

This Middleware *will disable itself if it detects the agent is any crawler or redditbot*, so SEO, Google, and reddit/twitter/opengraph fetches remain unaffected.

This is the cause of the `jaybizzle/laravel-crawler-detect` dependency. I planned to use GEOIP too at some point to be able to disable it on countries where the cookie law might not be important to comply but this is not implemented yet.

### Set active environments

[](#set-active-environments)

This package will only be active in the environments you specify, by default `stage`, `prod` and `production`, update `config/protectionbanner.php` if necessary:

```
    'enabled_environments' => ['stage', 'prod', 'production'],
```

### URL whitelist mechanism

[](#url-whitelist-mechanism)

This package also has a path exclusion mechanism I found useful in my projects. Even if a request is affected by this Middleware, a list of paths is checked, in a "whitelist" spirit, those URLS won't trigger the banner.

You can set this url whitelist in `config/protectionbanner.php`:

```
    'whitelist' => [
        'example/url',
        'example2'
    ],
```

### Logging

[](#logging)

I don't know if it's of any legal value, but it's possible to log the IP of all accepts of conditions. In `config/protectionbanner.php`:

```
    /*
     * Channel to log accept info, if necessary
     * Default: null
     * example: "accepts"
     */
    'logchannel' => "accepts"
```

You will of course need to add that channel to `config/logging.php`.

Important notes
---------------

[](#important-notes)

If you are using Cloudflare or some kind of proxy to serve your website, you need to make sure you configure TrustedProxy correctly *or this Middleware might not work correctly*.

Make sure you keep the config file `/config/trustedproxy.php` up to date, or `app\Http\Middleware\TrustProxies.php` , variable `$proxies`.

Change log
----------

[](#change-log)

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

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

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Markohs](https://github.com/markohs)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Total

7

Last Release

2283d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1194268?v=4)[Marcos Lopez](/maintainers/Markohs)[@Markohs](https://github.com/Markohs)

---

Top Contributors

[![Markohs](https://avatars.githubusercontent.com/u/1194268?v=4)](https://github.com/Markohs "Markohs (8 commits)")

---

Tags

adultcookiecookie-consentcookie-lawlaravelmiddlewaremiddlewarelaravelcookiesadultProtectionBanner

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/markohs-protectionbanner/health.svg)

```
[![Health](https://phpackages.com/badges/markohs-protectionbanner/health.svg)](https://phpackages.com/packages/markohs-protectionbanner)
```

###  Alternatives

[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

241641.4k1](/packages/tzsk-otp)[masterro/laravel-xss-filter

Filter user input for XSS but don't touch other html

41254.5k](/packages/masterro-laravel-xss-filter)[stevenmaguire/laravel-middleware-csp

Provides support for enforcing Content Security Policy with headers in Laravel responses.

39107.6k](/packages/stevenmaguire-laravel-middleware-csp)[laragear/poke

Keep your forms alive, avoid TokenMismatchException by gently poking your Laravel app

2211.5k](/packages/laragear-poke)

PHPackages © 2026

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