zencule/cookie-banner 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zencule/cookie-banner

最新稳定版本:0.2.1

Composer 安装命令:

composer require zencule/cookie-banner

包简介

A modern, customizable cookie consent banner for Laravel and Statamic applications

README 文档

README

A modern, customizable cookie consent banner for Laravel and Statamic applications. Built with Alpine.js and plain CSS (no Tailwind required).

License

Features

  • 🎨 Modern, responsive design with plain CSS (no Tailwind required)
  • ⚡ Smooth animations with Alpine.js
  • 📊 Google Analytics integration
  • 🔒 GDPR-compliant with essential/all cookies options
  • 🎯 Works with both Laravel and Statamic
  • ⚙️ Fully customizable through config

Installation

You can install the package via composer:

composer require zencule/cookie-banner

CSS

The package includes a plain CSS file for styling. To use the default styles, import or copy cookie-banner.css from the package's resources/ directory into your project and include it in your main CSS or HTML:

<link rel="stylesheet" href="/path/to/cookie-banner.css">

Or, if using a bundler:

import 'cookie-banner/resources/cookie-banner.css';

Laravel

The package will automatically register its service provider.

Publish the configuration file:

php artisan vendor:publish --tag=cookie-banner

Statamic

The package will automatically register as a Statamic addon.

Publish the configuration file:

php artisan vendor:publish --tag=cookie-banner

Usage

Laravel

Add the cookie banner to your layout file:

@include('cookie-banner::banner')

Statamic

Add the cookie banner to your layout file:

{{ zencule:cookie-banner }}

Configuration

Configure the banner in config/cookie-banner.php:

return [
    'privacy_policy_url' => env('COOKIE_BANNER_PRIVACY_URL', '/privacy-policy'),
    
    'analytics_id' => env('COOKIE_BANNER_ANALYTICS_ID', ''),
    
    'messages' => [
        'banner_text' => 'We use cookies to improve your experience...',
        'essential_button' => 'Essential Only',
        'accept_button' => 'Accept All',
        'more_info' => 'More Information',
    ],
];

Customization

Styling

The banner uses plain CSS classes by default. You can customize the appearance by:

  1. Publishing the views:
php artisan vendor:publish --tag=cookie-banner
  1. Modifying the templates in:

    • Laravel: resources/views/vendor/cookie-banner/blade/banner.blade.php
    • Statamic: resources/views/vendor/cookie-banner/antlers/banner.antlers.html
  2. Editing the CSS file:

    • Copy or import resources/cookie-banner.css and modify it as needed for your branding.

Analytics

By default, the package supports Google Analytics. Set your Analytics ID in your .env file:

COOKIE_BANNER_ANALYTICS_ID=G-XXXXXXXXXX

The script will only load after the user accepts all cookies.

Requirements

  • PHP 8.1 or higher
  • Laravel 10.0 or higher
  • Statamic 4.0 or higher (for Statamic integration)
  • Alpine.js

Contributing

Please see CONTRIBUTING.md for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 81
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-09