定制 taki47/laravel-cookie-consent 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

taki47/laravel-cookie-consent

最新稳定版本:v1.0.5

Composer 安装命令:

composer require taki47/laravel-cookie-consent

包简介

Advanced Laravel GDPR cookie consent manager with categorized consent and automatic script blocking.

README 文档

README

A modern, lightweight, and fully self-contained GDPR-ready privacy panel for Laravel.
Automatically detects, blocks, and manages analytics and marketing scripts with zero external dependencies.

Features

  • Automatic detection and blocking of tracking scripts
  • Dynamic cookie categories (necessary / statistics / marketing)
  • AJAX-based consent saving (no page reload)
  • Google Consent Mode v2 support
  • Cookie cleanup when consent is revoked
  • Re-openable floating icon
  • Artisan command for cache cleanup
  • Simple publish and setup process
  • Compatible with Laravel 10, 11, and 12+

Installation

Install via Composer:

composer require taki47/laravel-privacy-panel

Publish assets:

php artisan vendor:publish --provider="Taki47\PrivacyPanel\PrivacyPanelServiceProvider" --tag=public

This will publish: public/vendor/privacy-panel/

Before going live, scan your site so the banner can display cookie details (name, purpose, expiry) correctly:

php artisan cookie:scan

IMPORTANT: Before running the scan, make sure that APP_URL is set in your .env file to the website URL that the crawler needs to scan! Alternatively, you can pass the URL as an argument.

The cookie:scan command supports the following optional parameters:

  • {url? : (Optional) The website URL to scan, defaults to APP_URL}
  • {--depth=2 : Crawl depth (default 2)}
  • {--max-pages=100 : Maximum pages to crawl}
  • {--fetch-external-js : Also fetch external JS files (may slow down)}
  • {--delay=250 : Delay between requests in ms (politeness)}

Include the consent banner in your base layout (for example layouts/app.blade.php):

@include('privacy-panel::banner')

Load the cookie script before any analytics scripts:

<script src="{{ asset('vendor/privacy-panel/js/panel.js') }}"></script>

Artisan command

Clear cached cookie metadata and scan results:

php artisan cookie:clear-cache

Use --force to skip confirmation:

php artisan cookie:clear-cache --force

How it works

Automatic script blocking Known analytics and marketing scripts are detected and converted to <script type="text/plain"> before execution.

User consent handling User preferences are saved via AJAX to the cookie-consent.store route.

Re-enabling approved scripts Scripts belonging to approved categories (e.g., statistics, marketing) are dynamically reactivated without page reload.

Consent updates and cleanup When a user revokes consent, the package deletes related cookies and updates Google Consent Mode accordingly.

Contributing

Pull requests are welcome! Please follow PSR-12 coding standards and use English comments only.

License

Released under the MIT License. © 2025 Lajos Takacs <takiwebneked.hu>

Support

If you find this package useful, please give it a star on GitHub ⭐ Your support helps keep the project open and actively maintained.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固