ezsystems/privacy-cookie-bundle
最新稳定版本:v1.0.0-beta8
Composer 安装命令:
composer require ezsystems/privacy-cookie-bundle
包简介
Privacy cookie banner integration bundle into regular Symfony 2.x application (supports eZ Publish/eZ Platform)
README 文档
README
This bundle adds privacy cookie banner into Symfony applications.
Requirements
- Symfony v2.6 or later (including Symfony 3.x)
Installation
This package is available via Composer, so the instructions below are similar to how you install any other open source Symfony Bundle.
Run the following command in a terminal, from your Symfony installation root (pick most recent release):
php composer.phar require ezsystems/privacy-cookie-bundle
Enable the bundle in app/AppKernel.php file:
$bundles = array( // existing bundles new EzSystems\PrivacyCookieBundle\EzSystemsPrivacyCookieBundle(), );
Add external assets to your bundle:
- CSS:
bundles/ezsystemsprivacycookie/css/privacycookie.css
- JS:
bundles/ezsystemsprivacycookie/js/privacycookie.js
Assetic (Optional)
Enable the Assetic bundle in app/AppKernel.php file:
$bundles = array( // ... // starting from Symfony 2.8 you have to enable AsseticBundle manually if you haven't done it before new Symfony\Bundle\AsseticBundle\AsseticBundle() );
Add the following minimal configuration in config.yml file to enable Assetic support in your application (Symfony 2.8 and later):
assetic: debug: '%kernel.debug%' use_controller: '%kernel.debug%' filters: cssrewrite: ~
If you are installing the bundle via composer require you must also copy assets to your project's web directory. You can do this by calling Symfony's built-in command from the project root directory:
For Symfony 2.x:
php app/console assets:install --symlink
For Symfony 3.x:
php bin/console assets:install --symlink
In production environment you have to dump assets using Assetic built-in command:
For Symfony 2.x:
php app/console assetic:dump -e=prod
For Symfony 3.x:
php bin/console assetic:dump -e=prod
Usage
Insert the following {{ show_privacy_cookie_banner(%privacy_policy_url%) }} helper somewhere in your footer template before the body ending tag. Replace the %privacy_policy_url% parameter with your policy page address.
Note that the %privacy_policy_url% parameter is not required, in this case no policy link will be shown.
The following optional parameters can be set as a second argument in an array format:
| Parameter | Default value | Description |
|---|---|---|
| cookieName | privacyCookieAccepted | Sets your own status cookie name |
| cookieValidity | 365 | Says how many days privacy banner should be hidden when user accepts policy? |
| cookiePath | null | Specifies the cookie path (by default cookie will be available only for the current domain) |
| caption | Cookies help us create a good experience (...) | Sets your own banner message caption |
| learnMoreText | Learn More | Sets title and text of privacy link |
| extraParams | Extra Params | Send extra params in your override template |
Example of usage in standard Symfony application:
{{ show_privacy_cookie_banner('http://ez.no/Privacy-policy') }}
or
{{ show_privacy_cookie_banner('http://ez.no/Privacy-policy', {
cookieName: 'myCookie',
cookieValidity: 7,
cookiePath: '/',
caption: 'Nice to see you here',
learnMoreText: 'Find out more'
}) }}
If you are using eZ Publish / Platform you can use ez_urlalias to generate path for specified content object:
{{ show_privacy_cookie_banner(path('ez_urlalias', {contentId: 94}), {
cookieName: 'myCookie',
cookieValidity: 7,
caption: 'Nice to see you here'
}) }}
Example of usage extraParams:
{{ show_privacy_cookie_banner('http://ez.no/Privacy-policy', {
cookieName: 'myCookie',
extraParams: {
my_param1: value_my_param1 ,
my_param2: value_my_param2
}
}) }}
ezsystems/privacy-cookie-bundle 适用场景与选型建议
ezsystems/privacy-cookie-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27.8k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「twig」 「cookies」 「Policy」 「privacy」 「ezpublish」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ezsystems/privacy-cookie-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ezsystems/privacy-cookie-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ezsystems/privacy-cookie-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
A Twig extension to insert css as inline styles with a tag
Caching and compression for Twig assets (JavaScript and CSS).
The bundle for easy using json-rpc api on your project
Twig extensions for Tracy Debugger
统计信息
- 总下载量: 27.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 22
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2015-04-08
