百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

laravel-cookie-consent

> 后端框架
开源

一款符合 GDPR 要求的解决方案,为 Laravel 应用程序提供完全可自定义的 Cookie 标记,实现企业级的合规性。

184 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

一款符合 GDPR 要求的解决方案,为 Laravel 应用程序提供完全可自定义的 Cookie 标记,实现企业级的合规性。

Laravel Cookie Consent

A GDPR-compliant solution offering enterprise-grade compliance with fully customizable cookie banners for Laravel applications. Simplifies regulatory requirements while maintaining excellent user experience and complete customization capabilities.

Features

  • One-Click Implementation – Simple installation via Composer with auto-loaded assets
  • ⚡ Zero Performance Impact – Lightweight with lazy-loaded components
  • RTL & i18n Support – Full right-to-left compatibility + multilingual translations
  • Dark Mode Support – Auto dark/light mode matching system preferences
  • Granular Consent Control – Category-level cookie management (necessary/analytics/marketing)
  • Complete Customization – Override every color, text, and layout via config
  • Responsive Design – Perfectly adapts to all devices (mobile/tablet/desktop)
  • No Frontend Dependencies – No jQuery, Bootstrap, or Tailwind required — works everywhere effortlessly

Live Demo

Try the Live Demo


Installation

To get started with Cookie Consent, follow these simple steps:

  1. Install the package via Composer:
bash
composer require devrabiul/laravel-cookie-consent
  1. Publish the package resources by running: (Normal publish)
bash
php artisan vendor:publish --provider="Devrabiul\CookieConsent\CookieConsentServiceProvider"

Basic Usage

Include these components in your Blade templates:

  1. Add styles in the `` section:
php
{!! CookieConsent::styles() !!}
  1. Add scripts before closing ``:
php
{!! CookieConsent::scripts() !!}

Complete Example

php

    
    
    Your Page
    {!! CookieConsent::styles() !!}

    
    {!! CookieConsent::scripts() !!}

Advanced Configuration

…

Enable Dark Mode

Add theme="dark" to your `` tag to automatically enable dark mode.

xml

Theme Preset Support

This package now supports preset color themes for cookie banners. You can choose from:

Preset Description
basic Default neutral theme, clean and simple.
modern-blue Professional blue style, ideal for SaaS/web apps.
trust-green Privacy-friendly green, promotes trust and eco-friendly vibes.
soft-neutral Minimal soft gray, subtle and non-intrusive.
dark Dark mode theme, low-light friendly.

How to configure

In config/cookie-consent.php:

php
/*
|--------------------------------------------------------------------------
| Theme Preset
|--------------------------------------------------------------------------
| basic        - Default neutral theme
| modern-blue  - Professional blue style
| trust-green  - Privacy-friendly green style
| soft-neutral - Minimal soft gray theme
| dark         - Dark theme
*/
'theme_preset' => env('COOKIE_CONSENT_THEME_PRESET', 'basic'),

Enable RTL Mode

Add dir="rtl" to your `` tag to enable right-to-left layout for RTL languages.

xml

Layout Options

Config Status Control

bash
COOKIE_CONSENT_ENABLED=true
COOKIE_CONSENT_PREFERENCES_ENABLED=true
COOKIE_CONSENT_ASSET_URL=https://your-domain.com // if you are in localhost, avoid this or put null

COOKIE_CONSENT_ANALYTICS=true
COOKIE_CONSENT_MARKETING=true
COOKIE_CONSENT_PREFERENCES=true

Consent Modal Styles

  • box - Compact floating dialog
  • box-inline - Inline positioned box
  • box-wide - Expanded floating dialog
  • cloud - Modern floating design
  • cloud-inline - Compact cloud variant
  • bar - Top/bottom banner
  • bar-inline - Compact banner

Default: box-wide

Preferences Modal Styles

  • bar - Full-width layout
  • box - Centered popup

Default: bar

Configuration

Edit config/cookie-consent.php to modify:

  • Cookie lifetimes
  • Custom asset URL
  • Visual styles
  • Text content
  • Category settings

Example service loader (replace with your actual implementation)

…

Change Cookie Preferences Link

To comply with UK ICO and GDPR regulations, users must be able to revisit and update their cookie preferences at any time. This package now supports that functionality out of the box.

You can add a link anywhere on your site to let users open the cookie preferences modal again and update their choices:

xml
Change Cookie Preferences

Or use the class-based approach (useful if you want to attach event handlers via JavaScript or multiple links):

xml
Change Cookie Preferences

How It Works

  • Clicking the link will show the cookie preferences modal, allowing the user to change their settings.
  • This feature resets the consent banner/modal visibility so users can modify their choices in compliance with the ICO’s requirement.
  • The modal respects existing preferences but allows full customization and saving new preferences.

Compliance with UK ICO and GDPR

This package is designed to help your Laravel application meet the requirements of the UK Information Commissioner’s Office (ICO) and the GDPR by:

  • Providing explicit, granular cookie consent with customizable categories (e.g., necessary, analytics, marketing, preferences).
  • Allowing users to easily revisit and change their cookie preferences at any time using the “Change Cookie Preferences” link.
  • Supporting clear cookie banners and modals with translations and accessibility considerations.
  • Enabling consent logging and event dispatching for auditing and analytics purposes.

For more details, please review the UK ICO guidance on cookies: ICO Guide to Cookies and Similar Technologies


Get Started Today!

Experience the magic of CookieConsent and enhance your Laravel applications with Cookie Consent.

GitHub: Laravel Cookie Consent
**Packagist: ** https://packagist.org/packages/devrabiul/laravel-cookie-consent

Contributing

We welcome contributions to CookieConsent! If you would like to contribute, please fork the repository and submit a pull request. For any issues or feature requests, please open an issue on GitHub.

Please:

  1. Fork the repository
  2. Create your feature branch
  3. Submit a pull request

License

This package is open-sourced software licensed under the MIT license.

Treeware

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Contact

For support or inquiries, please reach out to us at Send Mail.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPcookie-consentgdprgdpr-cookielaravel

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架