synolia / sylius-gdpr-plugin
Synolia sylius GDPR plugin.
Package info
github.com/synolia/SyliusGDPRPlugin
Type:sylius-plugin
pkg:composer/synolia/sylius-gdpr-plugin
Requires
- php: ^8.3
- phpdocumentor/reflection-docblock: ^5.3
- sylius/sylius: ^2.2.13
- symfony/property-info: ^6.4|^7.4|^8.0
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.4
- phpmd/phpmd: ^2.15.0 || ^3.0
- phpro/grumphp: ^2.9
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^2.0
- phpstan/phpstan-doctrine: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpstan/phpstan-webmozart-assert: ^2.0
- phpunit/phpunit: ^9.5
- povils/phpmnd: ^3.0
- rector/rector: ^2.0
- squizlabs/php_codesniffer: ^3.11
- sylius-labs/coding-standard: ^4.3
- sylius/test-application: ^2.2.0@alpha
- symfony/browser-kit: ^6.4|^7.4|^8.0
- symfony/css-selector: ^6.4|^7.4|^8.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v2.1.0
- v2.0.0
- v1.7.0
- v1.6.0
- v1.5.1
- v1.5.0
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- dev-chore/drop-symfony-64-compat
- dev-chore/dev-tools
- dev-chore/supported-versions
- dev-chore/test-application
- dev-docs/upgrade-2.1-behaviour-changes
- dev-docs/update-readme
- dev-chore/drop-sylius-2.1
- dev-fix/issue-58
- dev-feature/add-remove-customer-without-any-orders-option
This package is auto-updated.
Last update: 2026-12-02 08:35:21 UTC
README
Sylius GDPR Plugin
Help your Sylius store comply with the GDPR: anonymize customers and export their personal data from the admin panel or the command line.
Features
- Anonymize a customer from the GDPR section of the admin customer page.
- Export customer data as a JSON file from the same section.
- Bulk anonymization from the GDPR admin page: customers who have not logged in since a given date, or customers without any order.
- Anonymize any entity from the command line.
- Configurable anonymization (YAML mappings or PHP attribute) and export (Symfony Serializer groups).
- Extensible: events around anonymization and export, custom bulk actions.
Requirements
| Version | |
|---|---|
| PHP | ^8.3 (8.4+ for Symfony 8) |
| Sylius | ^2.2.13 |
| Symfony | ^6.4 | ^7.4 | ^8.0 |
Installation
-
Require the plugin:
composer require synolia/sylius-gdpr-plugin
-
Register the bundle in
config/bundles.phpif Symfony Flex did not do it:Synolia\SyliusGDPRPlugin\SynoliaSyliusGDPRPlugin::class => ['all' => true],
-
Import the configuration in
config/packages/synolia_sylius_gdpr.yaml:imports: - { resource: "@SynoliaSyliusGDPRPlugin/Resources/config/app/config.yaml" }
-
Import the admin routes in
config/routes/synolia_sylius_gdpr.yaml:synolia_gdpr: resource: "@SynoliaSyliusGDPRPlugin/Resources/config/routes.yaml" prefix: '/%sylius_admin.path_name%'
-
Clear the cache:
php bin/console cache:clear
Anonymization
Default mappings
The plugin ships with mappings for the Sylius Customer, ShopUser, Address, Order and Payment entities:
see src/Resources/config/mappings.
Custom mappings
Add your own mapping directories, and optionally disable the default mappings:
synolia_sylius_gdpr: disable_default_mappings: false # default: false anonymization: mappings: paths: - '%kernel.project_dir%/config/gdpr/mappings'
Each file maps the properties of a class:
Sylius\Component\Core\Model\Customer: properties: firstName: faker: firstName prefix: 'anonymized-' lastName: value: 'Fake lastName' phoneNumber: ~ # set to null defaultAddress: ~ # related entity: anonymized with its own mapping orders: ~ # collection: each item is anonymized with its own mapping
You can also configure a property with the #[Anonymize] attribute, which accepts the same options:
use Synolia\SyliusGDPRPlugin\Attribute\Anonymize; class Customer extends BaseCustomer { #[Anonymize(['faker' => 'email', 'unique' => true, 'prefix' => 'anonymized-'])] protected $email; }
| Option | Description |
|---|---|
faker |
Faker formatter used to generate the value, e.g. email, lastName |
args |
Arguments passed to the Faker formatter, e.g. [20] |
unique |
Generates a unique value (Faker unique() modifier) |
prefix |
String prepended to the generated value |
value |
Fixed value: null, a string, an int, an array or an expression |
Dynamic values
A value starting with @= is evaluated with the Expression Language.
The object variable is the entity being anonymized:
Sylius\Component\Core\Model\Customer: properties: email: value: '@="anonymized-" ~ object.getId() ~ "@example.com"'
Command
Anonymize any entity from the command line:
php bin/console synolia:gdpr:anonymize --entity='Sylius\Component\Core\Model\Customer' --id=1
| Option | Description |
|---|---|
--entity/-E |
Fully qualified class name of the entity |
--id/-i |
Identifier of the entity. Without it, every entity of the class is anonymized |
--force |
Skips the confirmation question |
--reset |
Resets the Faker unique generator |
--max-retries |
Maximum number of retries to get unique values |
Customer data export
The export serializes the customer with the synolia:gdpr:customer_data serialization group
(Synolia\SyliusGDPRPlugin\Enum\GDPRSerializationKeyEnum::CUSTOMER_DATA).
See the default configuration in src/Resources/config/serialization.
To export more data, add this group to your own serialization mapping, for example with an attribute:
use Symfony\Component\Serializer\Attribute\Groups; use Synolia\SyliusGDPRPlugin\Enum\GDPRSerializationKeyEnum; class Customer extends BaseCustomer { #[Groups([GDPRSerializationKeyEnum::CUSTOMER_DATA])] protected ?string $loyaltyNumber = null; }
Custom bulk actions
The GDPR admin page lists bulk anonymization forms. To add yours:
-
Create a form type, and pass it to the controller with the
$formsTypeargument:services: Synolia\SyliusGDPRPlugin\Controller\AdvancedActionsController: arguments: $formsType: - App\Form\Type\AnonymizeCustomersFromCountryType tags: ['controller.service_arguments']
-
Create a processor implementing
Synolia\SyliusGDPRPlugin\Processor\AdvancedActions\AdvancedActionsFormDataProcessorInterface. It is registered automatically thanks to autoconfiguration.getFormTypesClass()returns the form types it handles, andprocess()receives the submitted form.
See AnonymizeCustomersNotLoggedBeforeProcessor for an example.
Events
| Event | Dispatched |
|---|---|
Synolia\SyliusGDPRPlugin\Event\BeforeAnonymize |
Before anonymizing any entity |
Synolia\SyliusGDPRPlugin\Event\AfterAnonymize |
After anonymizing any entity |
Synolia\SyliusGDPRPlugin\Event\BeforeCustomerAnonymize |
Before anonymizing a customer from the admin page |
Synolia\SyliusGDPRPlugin\Event\AfterCustomerAnonymize |
After anonymizing a customer from the admin page |
Synolia\SyliusGDPRPlugin\Event\BeforeExportCustomerData |
Before exporting the customer data |
Development
The plugin is developed and tested with the Sylius Test Application:
make install # optionally: make install -e SYLIUS_VERSION=2.2.0 SYMFONY_VERSION=6.4 make phpunit make serve # or: APP_ENV=test symfony server:start -d
Use vendor/bin/console to run Symfony commands against the test application.
See How to contribute for more details (database configuration, versions, ...).
License
This plugin is released under the EUPL-1.2 license.
Credits
Developed by Synolia.
