cyllene-digital / sylius-tarteaucitron-plugin
tarteaucitron.js cookie consent manager for Sylius.
Package info
github.com/CylleneDigital/SyliusTarteaucitronPlugin
Language:JavaScript
Type:sylius-plugin
pkg:composer/cyllene-digital/sylius-tarteaucitron-plugin
Requires
- php: ^8.2
- doctrine/collections: ^2.0
- doctrine/dbal: ^3.0 || ^4.0
- doctrine/doctrine-bundle: ^2.13 || ^3.1
- doctrine/migrations: ^3.6
- doctrine/orm: ^2.14 || ^3.0
- doctrine/persistence: ^3.0 || ^4.0
- sylius/sylius: ^2.1
- symfony/config: ^7.4 || ^8.0
- symfony/dependency-injection: ^7.4 || ^8.0
- symfony/finder: ^7.4 || ^8.0
- symfony/form: ^7.4 || ^8.0
- symfony/http-foundation: ^7.4 || ^8.0
- symfony/http-kernel: ^7.4 || ^8.0
- symfony/options-resolver: ^7.4 || ^8.0
- symfony/routing: ^7.4 || ^8.0
- symfony/security-http: ^7.4 || ^8.0
- symfony/service-contracts: ^3.5
- symfony/validator: ^7.4 || ^8.0
- symfony/yaml: ^7.4 || ^8.0
- twig/twig: ^3.10
Requires (Dev)
- behat/behat: ^3.22 || ^4.0
- behat/mink: ^1.11
- dbrekelmans/bdi: ^1.4
- dmore/chrome-mink-driver: ^2.9
- friends-of-behat/mink-browserkit-driver: ^1.6.3
- friends-of-behat/mink-debug-extension: ^2.1
- friends-of-behat/mink-extension: ^2.7 || ^3.0@alpha
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.6.2
- friends-of-behat/variadic-extension: ^1.7
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^10.5
- sylius-labs/behat-chrome-extension: ^1.5
- sylius-labs/coding-standard: ^4.4
- sylius-labs/suite-tags-extension: ~0.2
- sylius/test-application: ^2.0.0@alpha
- symfony/browser-kit: ^7.4 || ^8.0
- symfony/debug-bundle: ^7.4 || ^8.0
- symfony/dotenv: ^7.4 || ^8.0
- symfony/runtime: ^7.4 || ^8.0
- symfony/web-profiler-bundle: ^7.4 || ^8.0
- symfony/webpack-encore-bundle: ^2.4
Suggests
- nelmio/security-bundle: Per-response CSP nonce for the banner scripts (script_nonce_provider: nelmio)
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-05 15:49:43 UTC
README
Sylius Tarteaucitron Plugin
Open-source Sylius 2 plugin that performs the official tarteaucitron.js free, self-hosted install on a Sylius shop, with one configuration per channel:
- a back office to enable the banner, pick the services (46 built in) and tune the consent behaviour, with warnings when a setting departs from the CNIL cookie guidance;
- links and banner texts per channel locale, the banner language following the shop locale;
- the consent lifetime (6 months by default);
- vendor services and theme-level options from YAML, without code.
tarteaucitron® is a trademark of tarteaucitron.io. This plugin is an independent integration, neither affiliated with, sponsored by, nor endorsed by the tarteaucitron.io publisher. It implements the free open-source library only. The commercial (Pro) offering is neither required nor used.
The library is vendored under public/tarteaucitron/ and served from the shop
(assets:install). The plugin does not load tarteaucitron.js from a CDN and does not send
visitor data to tarteaucitron.io or logs.tarteaucitron.io.
Compatibility
| Component | Versions |
|---|---|
| PHP | ^8.2 (Sylius 2.3: ^8.3; Symfony 8: ^8.4) |
| Sylius | 2.1, 2.2, 2.3 |
| Symfony | ^7.4, or ^8.0 with Sylius 2.3 |
| tarteaucitron.js (vendored) | see public/tarteaucitron/VERSION (1.35.0) |
What this plugin does not do
- It only gates services declared in its back office (tarteaucitron job keys). A script hardcoded in the theme, or a tag loaded by GTM outside this plugin, is not under consent.
- It does not keep a server-side proof-of-consent log. The choice lives in the tarteaucitron cookie.
- It ships a Sylius-oriented selection of the about 250 upstream services; any other one can be declared in YAML or with a PHP class.
- Its CNIL warnings are guidance, not legal advice: compliance stays the merchant's responsibility.
Installation
composer config extra.symfony.allow-contrib true
composer require cyllene-digital/sylius-tarteaucitron-plugin
The Flex recipe
registers the bundle, imports the routes and adds a commented
config/packages/cyllene_digital_sylius_tarteaucitron.yaml. Without Flex, or with contrib recipes
off, do it by hand. Register the bundle:
// config/bundles.php CylleneDigital\SyliusTarteaucitronPlugin\CylleneDigitalSyliusTarteaucitronPlugin::class => ['all' => true],
Import the routes (back-office page):
# config/routes/cyllene_digital_sylius_tarteaucitron.yaml cyllene_digital_sylius_tarteaucitron: resource: '@CylleneDigitalSyliusTarteaucitronPlugin/config/routes.yaml'
Publish the assets and create the two plugin tables:
bin/console assets:install bin/console doctrine:migrations:migrate -n
Then, in the back office, Configuration → Tarteaucitron: enable tarteaucitron for the channel, switch on the services the shop uses, fill their identifiers and save. tarteaucitron stays off on a channel until then, and every service starts switched off. The screen is described in the back-office guide.
Last, give visitors a way to change their choice at any time, e.g. a footer link the library wires itself (no inline JavaScript, so it works under a strict CSP):
<button type="button" id="manage-cookies" class="tarteaucitronOpenPanel">{{ 'app.footer.manage_cookies'|trans }}</button>
Configuration
Nothing is required. The bundle configuration holds what belongs to the integration rather than to a shop admin - CSP nonce (fixed, or per response with NelmioSecurityBundle), locale mapping, theme-level options (external CSS, panel anchor, ad-blocker message…) and vendor services without code:
# config/packages/cyllene_digital_sylius_tarteaucitron.yaml cyllene_digital_sylius_tarteaucitron: integration: custom_closer_id: manage-cookies # focus back on the footer link when the panel closes
Full reference, and what belongs in the back office instead: bundle configuration.
Adding services
Any vendor service can be offered from configuration; the container build fails on an unknown job
key, a user.* key the service never reads, or a job key already built in:
# config/packages/cyllene_digital_sylius_tarteaucitron.yaml cyllene_digital_sylius_tarteaucitron: trackers: smartsupp: # tarteaucitron job key category: support # analytic, ads, api, video, social, support, comment, other label: Smartsupp # back-office name (translation key or text), default: the job key parameters: smartsuppKey: # exact tarteaucitron.user.* key placeholder: 'xxxxxxxx' # required: true # default; false for optional keys # label: 'Smartsupp key' # embed: true # for services replacing HTML placeholders (videos, widgets)
For more (admin hint, Consent Mode link), extend AbstractTrackerDefinition in your application;
autoconfiguration tags it:
final class AcmeTracker extends AbstractTrackerDefinition { public function getType(): string { return 'acme'; } public function getCategory(): TrackerCategory { return TrackerCategory::Other; } public function getParameters(): array { return [new TrackerParameter('acme_id', 'acmeId')]; } }
See custom tracker (translation keys, embeds). To contribute a built-in tracker, see adding a tracker.
Embeds (YouTube, Maps, widgets)
Switch the service on in the back office; the placeholders stay in your theme, with the
tarteaucitron classes (e.g. youtube_player) of the
official install.
Twig helper: tarteaucitron_is_embed('youtube').
Troubleshooting: the banner does not show
- tarteaucitron is off for this channel, or was never saved: open Configuration → Tarteaucitron for that channel, enable it and save.
- No switched-on service needs consent. tarteaucitron.js only opens the banner when a service waits for a choice. A service switched on without its required identifier is not loaded (the back office warns "incomplete").
- Visitor already chose. The banner only shows again after the consent lifetime, or after
deleting the
tarteaucitroncookie (or the name set in the Advanced tab). - Assets missing or stale: a 404 on
bundles/cyllenedigitalsyliustarteaucitronplugin/…in the browser console. Runbin/console assets:installagain. - The theme does not render the
sylius_shop.base.headhook, where the plugin injects its snippet. - A Content-Security-Policy blocks the scripts: give the plugin's script tags your nonce with
script_nonce_provider(e.g.nelmio), see the bundle configuration. integration.use_external_css/use_external_jsare on without the theme providing the files they disable.
Upgrading
Upgrade the Composer package, then:
bin/console assets:install bin/console doctrine:migrations:migrate -n
and read UPGRADE.md.
assets:install matters on every upgrade: the vendored library and the plugin stylesheet are served
from the copy in public/bundles/, while their URLs carry a fingerprint of the package files, so
without it browsers fetch the new URL and get the old file. If your theme overrides
templates/shop/tarteaucitron.html.twig or an admin template, compare it with the new version.
The vendored tarteaucitron.js is upgraded by the maintainers with each release (how).
Public contract
The shop Twig hook and functions, the tracker extension API, the bundle configuration keys, the
admin hooks and route, and the database tables only change in a major version. Everything marked
@internal may change in a minor version. The full list and the support policy:
public contract.
Documentation
- Back-office guide - for shop admins
- Bundle configuration - for integrators
- Technical documentation - architecture, rendering, persistence, tests
Status
Exercised in a real browser: 22 Behat scenarios, 12 of them in headless Chrome against the banner and panel as tarteaucitron.js renders them (accept / deny / personalize, the floating icon with no service enabled, a channel in two locales with per-locale texts, the ad-blocker detection path) and the back-office services column. The shop and the back office were also walked by hand on a test application with two channels, one of them in English and French.
The continuous integration matrix covers Sylius 2.1 to 2.3, PHP 8.2 to 8.5, Symfony 7.4 and 8, on MySQL, MariaDB and PostgreSQL, every Behat scenario included.
Two limits come from elsewhere: Sylius 2.3 on MariaDB with DBAL 4 skips its own migrations (details), and a few tarteaucitron.js options are ignored in some setups - the back office says so next to the option (list).
The scope stops at the free tarteaucitron.js install: no server-side proof-of-consent log, no consent for scripts loaded outside the plugin (see "What this plugin does not do").
Contributing
CONTRIBUTING.md - environment, required checks, conventions.
A flaw is reported privately: SECURITY.md. Do not open it as a public issue.
Provenance and licence
The plugin is released under the MIT licence - see LICENSE.
The vendored tarteaucitron.js (public/tarteaucitron/) is © 2014 AmauriC, also under
the MIT licence; its own LICENSE is kept next to it and is not replaced by the plugin's.
Package: cyllene-digital/sylius-tarteaucitron-plugin
Maintained by Cyllene, on GitHub as @CylleneDigital


