phpnomad/privacy
Composer 安装命令:
composer require phpnomad/privacy
包简介
README 文档
README
phpnomad/privacy defines a small contract for answering a single question: can the current request be tracked? Application code that emits analytics, user-identifying events, or logs checks the bound strategy first, so consent policy lives in one place instead of being scattered across every call site.
Installation
composer require phpnomad/privacy
Overview
- Ships a single interface,
TrackingPermissionStrategy, with one method:canTrack(): bool. - Lets you centralize tracking consent in one replaceable strategy instead of repeating checks across analytics, event, and logging code.
- Stays platform-agnostic. The strategy you bind decides whether consent comes from a DNT header, a cookie banner, login state, or application-specific rules.
- Integration packages such as
phpnomad/wordpress-integrationship default strategies you can replace by binding your own in an initializer. - Has no runtime dependencies. It's a contract-only package that sits between your tracking code and whatever policy you choose to enforce.
Usage
Implement the interface in your application:
<?php namespace MyApp\Strategies; use PHPNomad\Privacy\Interfaces\TrackingPermissionStrategy; class CookieConsentTrackingStrategy implements TrackingPermissionStrategy { public function canTrack(): bool { return isset($_COOKIE['consent']) && $_COOKIE['consent'] === 'accepted'; } }
Bind it in your initializer alongside your other strategies:
<?php namespace MyApp; use MyApp\Strategies\CookieConsentTrackingStrategy; use PHPNomad\Loader\Interfaces\HasClassDefinitions; use PHPNomad\Privacy\Interfaces\TrackingPermissionStrategy; class AppInitializer implements HasClassDefinitions { public function getClassDefinitions(): array { return [ CookieConsentTrackingStrategy::class => TrackingPermissionStrategy::class, ]; } }
Then any code that emits tracking-sensitive output can ask the bound strategy before doing so.
Documentation
Full PHPNomad documentation lives at phpnomad.com.
License
MIT. See LICENSE.txt.
phpnomad/privacy 适用场景与选型建议
phpnomad/privacy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.08k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 phpnomad/privacy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpnomad/privacy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-18