Search by

tmonier / sylius-digital-product-passport-plugin

thibmonier

Digital Product Passport plugin for Sylius 2: open and versioned sustainability data model (origin, recyclability, repairability), public passport page, no regulatory compliance promise

Package info

github.com/thibmonier/sylius-digital-product-passport-plugin

Type:sylius-plugin

pkg:composer/tmonier/sylius-digital-product-passport-plugin

Statistics

Installs: 438

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 5

v0.4.0 2026-11-13 06:22 UTC

README

Build

🇫🇷 Version française

Open and versioned sustainability data model for Sylius 2 products: origin, recyclability, repairability, with a public passport page.

Important: This plugin provides a preparatory data model aligned with ESPR (EU) 2024/1781. It makes NO promise of regulatory compliance until delegated acts by product category are published.

Features

  • Versioned data model: a passport per product variant (product identifier, origin of materials, recyclability, repairability), with a version number and a revision history (PassportRevision, recorded by PassportRevisionService).
  • Public passport page: /product-passport/{id}, readable without an account, in English and French, showing the data, the passport version and the date of the last update. A passport with no data filled in is treated as unpublished and returns a 404.
  • Link from the product page: a "Product Passport" link in the product summary of the shop, through the sylius_shop.product.show.content.info.summary Twig hook.
  • JSON export: DigitalProductPassport::toJson() returns the passport with its schema version (schemaVersion).
  • GS1 Digital Link and QR code: when the passport product identifier is a valid GTIN (8, 12, 13 or 14 digits, check digit verified), the admin product edit page shows a "Labels" tab with the GS1 Digital Link (https://id.gs1.org/01/{GTIN}) and its QR code (SVG). An invalid GTIN is reported in the tab.
  • Compatible spare parts (optional): when tmonier/sylius-customer-asset-management-plugin is installed and the passport has an equipment model code, the public page lists the variants compatible with that equipment model, with a link to their product page; a disabled product is listed as unavailable, without link. Without that plugin, the block is not shown.
  • Passport on the machine page (optional, customer-asset-management ^0.2.1): on the page of a machine of the customer's fleet, a block links to the published passport of its equipment model (same equipment model code) and lists its compatible spare parts. A model without a published passport shows no block.

Planned for later versions: an admin interface to edit passports, SVG and PNG download of the QR code, more data fields.

Installation

composer require tmonier/sylius-digital-product-passport-plugin

Enable the plugin in config/bundles.php:

return [
    // ...
    Tmonier\SyliusDigitalProductPassportPlugin\TmonierSyliusDigitalProductPassportPlugin::class => ['all' => true],
];

Import the routes, for example in config/routes/tmonier_digital_product_passport.yaml:

tmonier_digital_product_passport:
    resource: '@TmonierSyliusDigitalProductPassportPlugin/config/routes.yaml'

Run the migrations:

bin/console doctrine:migrations:migrate

Usage

There is no admin screen to edit passports yet: passports are created in code (fixtures, import or a command of your own), for example:

$passport = new DigitalProductPassport();
$passport->setProductVariant($variant);
$passport->setOriginMaterials('France, Germany');
$passport->setRecyclability('100% recyclable');
$passport->setRepairability('Repairability index: 8/10');
$passport->setProductIdentifier('01234567890128'); // GTIN, used for the GS1 Digital Link
$passport->setEquipmentModelCode('FORKLIFT_X'); // optional, customer-asset-management equipment model
$entityManager->persist($passport);
$entityManager->flush();

The product page then links to the public page /product-passport/{id}.

Battery passport (public level)

Regulation (EU) 2023/1542, art. 77(1): from 18 February 2027, a battery passport is required for each LMT battery, each industrial battery with a capacity greater than 2 kWh and each electric vehicle battery. The public data are listed in annex XIII point 1 (including annex VI part A).

A passport can carry an optional battery profile (BatteryProfile, $passport->setBatteryProfile()); passports without it are unchanged.

  • Mandatory when a profile exists: category (BatteryCategory: LMT, industrial, electric vehicle, portable, SLI), chemistry, nominal capacity (Ah), nominal voltage (V), weight (kg), manufacturing date (month and year).
  • Optional: minimum and maximum voltage, manufacturing place, carbon footprint (kg CO2e/kWh), recycled content of cobalt, lithium, nickel and lead (%), renewable content share (%), expected cycle life, hazardous substances, critical raw materials, extinguishing agent, warranty duration.
  • Validation (Symfony Validator, validator->validate($passport)): a missing mandatory field is refused with a message that names it; percentages must be between 0 and 100, other values greater than 0. A portable or SLI battery is accepted and flagged with a notice, "Battery passport is not mandatory for this category (art. 77(1))" (BatteryScopeAdvisor, also shown on the public page). The 2 kWh threshold of industrial batteries is not checked.
  • Public page: a "Battery" section in English and French, with units, as a definition list. A revision (PassportRevision) records the profile like the other fields.
  • JSON export: a passport with a profile exports schemaVersion 2, which is version 1 plus a battery object. A passport without a profile still exports exactly the version 1 keys, so existing consumers are not affected.
$battery = new BatteryProfile();
$battery->category = BatteryCategory::Industrial;
$battery->chemistry = 'Lithium iron phosphate (LFP)';
$battery->nominalCapacityAh = 600.0;
$battery->nominalVoltageV = 48.0;
$battery->weightKg = 850.0;
$battery->manufacturedOn = new \DateTimeImmutable('2027-03-01'); // only month and year are shown
$passport->setBatteryProfile($battery);

Out of scope: the restricted access levels (legitimate interest, authorities) and the submission to the European battery passport registry (art. 77(10)). The plugin still makes no promise of regulatory compliance.

Screenshots

Public product passport page, as rendered in the Sylius B2B demo. Labels follow the shop locale; field values are stored as entered.

Public product passport page (English)

Public passport page of an industrial forklift battery: battery section with units (English)

Public product passport page (French)

Requirements

  • PHP 8.2 or higher
  • Sylius 2.2.9+ or 2.3+
  • Symfony 7.4 or 8.0 (tested in CI)

Development

make install        # Install dependencies
make test           # Run tests
make phpstan        # Run PHPStan
make ecs            # Check coding standards
make quality        # Run all quality checks

Regulatory Context

This plugin anticipates the Digital Product Passport obligation from ESPR (EU) 2024/1781:

  • Batteries: February 18, 2027 (Regulation (EU) 2023/1542, Art. 77)
  • Other categories: indicative roadmap (textiles Q4 2027, furniture 2028, etc.)

Disclaimer: This plugin provides a preparatory data structure. It makes NO guarantee of regulatory compliance until delegated acts define the exact data requirements for each product category.

Author

Thibaut Monier – AI Delivery Manager / Tech Lead

License

MIT License. See LICENSE for details.

Links