rstech / yii2-consent
Consent-first privacy, cookie, tracker and jurisdiction guard for Yii2 applications
Package info
gitlab.restsolution.tech/rstech/yii2-consent.git
Type:yii2-extension
pkg:composer/rstech/yii2-consent
Requires
- php: >=7.4
- yiisoft/yii2: ^2.0.49
Requires (Dev)
None
Suggests
- yiisoft/yii2-debug: Optional: enables the RSTech Consent panel in Yii Debug Toolbar during development.
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-09-09 09:41:29 UTC
README
rstech/yii2-consent is a consent/privacy layer built specifically for Yii2. It can block non-essential cookies, analytics, advertising tags, browser storage and external embeds until the visitor's decision, while keeping crawler/SSR output available. The package also supports a non-blocking notice mode when the operator explicitly chooses that model.
Current release: 0.18.0 · DB schema: 5 · Config schema: 4 · PHP: 7.4+ · Yii2: 2.0.49+
Canonical repository: https://gitlab.restsolution.tech/rstech/yii2-consent.git
Install
Recommended interactive installation:
composer require rstech/yii2-consent:^0.18
php yii consent/wizard
php yii consent/doctor
php yii consent/audit @app
If the package is not yet available from Packagist, add the canonical GitLab repository as a Composer VCS repository first. The full production procedure for Yii2 Basic and Advanced, VCS/Packagist installation, config discovery, ConsentSession, nginx/deploy checks and upgrades is in docs/INSTALL.md.
Что получает проект
strictconsent-first режим и отдельныйnoticeрежим;- modal или неблокирующая верхняя/нижняя панель;
- категории
necessary,preferences,analytics,advertising,external_media; - Purpose Registry и Service/Vendor Registry;
- SSR/crawler profile без tracker-логики и consent-cookie;
- pre-consent CSP, блокирование
script/iframe и необязательныхSet-Cookie; ConsentSession, чтобы Yii2 случайно не создавалPHPSESSIDдо решения;- Privacy Center, отзыв согласия и очистка известных cookies/storage;
- consent receipts в БД или JSONL;
- RU/EU/UK/California/global jurisdiction profiles;
- GPC support для профилей, где он применяется;
- статический инспектор существующего Yii2-проекта;
- Setup Wizard для человека и JSON/PHP preset для SiteOps/CI;
- Yii Debug Toolbar panel при установленном
yiisoft/yii2-debug; - convergent schema upgrades: свежая версия ставится напрямую, промежуточные релизы не обязательны.
Built-in integrations
Готовые widgets/adapters включают:
- Яндекс Метрика и РСЯ;
- Google Analytics 4, Google Tag Manager, Google Ads, Google Consent Mode v2;
- Meta Pixel;
- Microsoft Clarity;
- Hotjar;
- TikTok Pixel;
- LinkedIn Insight;
- Cloudflare Web Analytics;
- reCAPTCHA и Turnstile;
- YouTube и Google Maps;
- расширяемый custom Service Registry.
Полный список и примеры: docs/INTEGRATIONS.md.
Strict и notice
По умолчанию:
'consentMode' => 'strict',
'promptPresentation' => 'auto',
Неблокирующий UI с сохранением strict enforcement:
'consentMode' => 'strict',
'promptPresentation' => 'bar',
Информационное notice-only поведение:
'consentMode' => 'notice',
'promptPresentation' => 'bar',
'noticeText' => 'Продолжая пользоваться сайтом, вы соглашаетесь на обработку файлов cookie и данных метрических программ.',
notice — техническая возможность, а не автоматическое юридическое заключение. Для профилей, требующих prior consent, consent/doctor и consent/validate-config показывают предупреждение. Подробнее: docs/NOTICE-MODE.md.
First configuration
Для Yii2 Basic мастер создаёт @app/config/consent.php. Для Yii2 Advanced предпочитает @common/config/consent.php.
Пример минимальной конфигурации:
return [
'class' => \rstech\yii2consent\Module::class,
'enabled' => true,
'configVersion' => 5,
'jurisdiction' => 'ru',
'locale' => 'ru-RU',
'operatorName' => 'ООО «Компания»',
'policyVersion' => '2026-09-03',
'privacyPolicyUrl' => '/privacy',
'personalDataConsentUrl' => '/personal-data-consent',
'services' => [
'yandex_metrica' => [],
'google_analytics' => [],
],
];
Diagnostics
php yii consent/status
php yii consent/validate-config
php yii consent/doctor
php yii consent/doctor json
php yii consent/inspect @app
php yii consent/audit @app
doctor предназначен как финальный readiness-check после установки и для SiteOps/CI.
Upgrade model
Не требуется вручную ставить v1 → v2 → v3. Текущий код приводит любую поддерживаемую старую схему непосредственно к целевой:
composer update rstech/yii2-consent
php yii consent/upgrade
php yii consent/doctor
Подробно: docs/UPGRADING.md.
Free / Pro
Free остаётся полностью работоспособным без лиценз-сервера. rstech/yii2-consent-pro добавляет Privacy Operations: dashboard, аудит, monitoring, evidence, DSAR, Policy Manager, Visual Builder и Processing Registry. Сравнение: docs/EDITIONS.md.
Documentation
- Installation
- Setup Wizard
- Integrations
- International profiles
- Notice mode
- Upgrade model
- Packagist / Composer
- Release checklist
Legal scope
The package is a technical control layer. It does not automatically determine the operator's lawful basis, retention period, required notices, cross-border transfer rules or correctness of legal documents. Those decisions remain project-specific.
License
MIT.
Integration verification
After setup or after adding third-party code, run:
php yii consent/integration-check @app
php yii consent/integration-check @app json
This is a static, no-browser/no-network comparison of detected services/hosts/session usage against the configured consent registry.
Production validation
php yii consent/doctor
php yii consent/integration-check @app
php yii consent/production-check @app
See decision lifetime and production self-check.