11 KiB
UPGRADE FROM 2.2 TO 2.3
Configuration
-
The default value of
sylius_core.order_by_identifierhas been changed fromtruetofalse. (#18956)The
OrderByIdentifierSqlWalkeris no longer enabled by default. If your application relies on ordering by identifier, enable it explicitly in your configuration:sylius_core: order_by_identifier: true -
Configuration changes related to the broadened Doctrine support (see the Dependencies section). These only matter once you opt into DoctrineBundle 3 / DBAL 4:
-
The
auto_generate_proxy_classes: "%kernel.debug%"option was removed from Sylius' Doctrine configuration (it no longer exists in DoctrineBundle 3, and since PHP 8.4 Doctrine uses native lazy objects). If you are still on DoctrineBundle 2 and rely on this behavior, set it explicitly in your own application configuration. -
The ORM metadata/query/result cache configuration was switched from wrapped
Doctrine\Common\Cacheservices to PSR-6 cache pools (type: pool). This change lives in the application configuration (config/packages/{prod,test}/doctrine.yaml), which is not updated automatically on existing installations, update those files in your project accordingly:doctrine: orm: entity_managers: default: metadata_cache_driver: - type: service - id: doctrine.system_cache_provider + type: pool + pool: doctrine.system_cache_poolAs part of this switch, the
doctrine.result_cache_provideranddoctrine.system_cache_providerservices (defined in Sylius' application configuration, wrapping the PSR-6 pools viaDoctrine\Common\Cache\Psr6\DoctrineProvider) were removed. If you referenced them by id, use the cache pools directly (doctrine.system_cache_pool,doctrine.result_cache_pool) withtype: poolas shown above. -
On PostgreSQL, Sylius now forces the
SEQUENCEidentity generation strategy (identity_generation_preferencesforPostgreSQLPlatform) to keep the database schema backward compatible with existing installations.
-
-
The
_sylius: redirect:block has been removed from thesylius_shop_order_payroute definition.Previously,
PayumPayResponseProviderread the after-pay redirect route at runtime from the routing metadata:# ShopBundle/Resources/config/routing/order.yml (removed) sylius_shop_order_pay: defaults: _sylius: redirect: route: sylius_shop_order_after_payThe redirect route is now resolved from the
sylius_shopbundle configuration at compile time. If you customized the after-pay redirect route for Payum, use the dedicated Payum configuration keys instead:sylius_shop: order_pay: payum_after_pay_route: sylius_shop_order_after_pay payum_after_pay_route_parameters: []Note: The
after_pay_routeandafter_pay_route_parameterskeys are reserved for the Payment Request flow and their default parameters include Payment Request-specific values (e.g.hash: paymentRequest.getHash()). Do not use them to configure the Payum after-pay redirect.
Dependencies
-
The
behat/transliteratorpackage has been deprecated and will be removed in Sylius 3.0.Slug generation now primarily uses
symfony/string(Symfony\Component\String\Slugger\SluggerInterface). When no$sluggeris injected, the system falls back toBehat\Transliterator\Transliterator, but this fallback behavior is deprecated and will be removed in Sylius 3.0.The following classes have been updated — if you have extended or decorated them, update your constructor accordingly:
-
Sylius\Component\Product\Generator\SlugGenerator:-public function __construct() +public function __construct(private ?SluggerInterface $slugger)Deprecated: Passing
nullas$slugger(or omitting it) is deprecated since Sylius 2.3. Whennullis passed, the generator falls back toBehat\Transliterator\Transliterator. Both the nullable argument and thebehat/transliteratorfallback will be removed in Sylius 3.0. -
Sylius\Component\Taxonomy\Generator\TaxonSlugGenerator:-public function __construct() +public function __construct(private ?SluggerInterface $slugger)Deprecated: Same as above.
-
Sylius\Bundle\AdminBundle\Generator\TaxonSlugGenerator:public function __construct( private BaseTaxonSlugGeneratorInterface $slugGenerator, + private ?SluggerInterface $slugger, )Deprecated: Same as above.
The
StringInflector::nameToSlug()method has been deprecated and will be removed in Sylius 3.0. -
-
The
knplabs/gaufretteandknplabs/knp-gaufrette-bundlepackages have been removed.The Gaufrette integration has been unusable as a filesystem adapter. Since Sylius 2.0 the default filesystem adapter uses Flysystem instead.
If your application depends on the Gaufrette packages directly, require them explicitly in your
composer.json. -
The
symfony/proxy-manager-bridgeandfriendsofphp/proxy-manager-ltspackages have been removed.They are no longer needed, lazy services now rely on PHP's native lazy proxies provided by
symfony/var-exporter(the default since Symfony 6.4). No change is required in your application.If your application depends on these packages directly, require them explicitly in your
composer.json. -
The supported Doctrine version ranges have been broadened to allow the newer stack (
doctrine/doctrine-bundle^2.13 || ^3.0,doctrine/dbal^3.9 || ^4.0,doctrine/persistence^3.3 || ^4.0,doctrine/data-fixtures^1.7 || ^2.2).DBAL 4 removes the built-in
objectandarraycolumn types. Since Sylius maps two fields astype="object"(PaymentSecurityToken.detailsandPaymentRequest.payload), it registers a customSylius\Bundle\PaymentBundle\Doctrine\DBAL\Type\ObjectTypeto keep them working.
Validation
-
Passing an array of options to configure a Sylius validation constraint is deprecated since Sylius 2.3 and will be removed in Sylius 3.0. Use named arguments instead.
All Sylius validation constraints now declare explicit constructors with named arguments (marked with
#[HasNamedArguments]). The legacy array syntax keeps working, it only triggers deprecation.Configuring constraints via XML / YAML / PHP attributes is not affected and requires no changes; the validator loaders pass the options as named arguments automatically. Only direct instantiation in PHP should be migrated:
-new ProvinceAddressConstraint(['message' => 'My custom message']) +new ProvinceAddressConstraint(message: 'My custom message') -
Several constraint message options have been renamed to follow the consistent
*Messageconvention. The old option names and public properties are deprecated since Sylius 2.3 and will be removed in Sylius 3.0. Both keep working and stay in sync in the meantime; switch to the new*Messagename:Constraint Old New ApiBundle\...\ChosenPaymentMethodEligibilitynotAvailable,notExist,paymentNotFoundnotAvailableMessage,notExistMessage,paymentNotFoundMessageApiBundle\...\ChosenPaymentRequestActionEligibilitynotAvailable,notExistnotAvailableMessage,notExistMessageApiBundle\...\AddingEligibleProductVariantToCartproductVariantNotSufficientproductVariantNotSufficientMessageApiBundle\...\ChangedItemQuantityInCartproductVariantNotLongerAvailable,productVariantNotSufficientproductVariantNotLongerAvailableMessage,productVariantNotSufficientMessagePromotionBundle\...\PromotionRuleType,PromotionActionType,CatalogPromotionActionType,CatalogPromotionScopeTypeinvalidTypeinvalidTypeMessagePaymentBundle\...\GatewayFactoryExistsinvalidGatewayFactoryinvalidGatewayFactoryMessageShippingBundle\...\ShippingMethodCalculatorExistsinvalidShippingCalculatorinvalidShippingCalculatorMessageShippingBundle\...\ShippingMethodRuleinvalidTypeinvalidTypeMessage
Promotion
-
New opt-in per-channel promotion rule and action types have been added. They let a single promotion rule/action hold independent configuration per channel, with the
configurationarray keyed by channel code (e.g.['WEB_US' => ['count' => 2], 'WEB_GB' => ['count' => 5]]):- Rules:
cart_quantity_per_channel,customer_group_per_channel,nth_order_per_channel,shipping_country_per_channel,has_taxon_per_channel,contains_product_per_channel. - Actions:
order_percentage_discount_per_channel,shipping_percentage_discount_per_channel.
These are additional types registered alongside the existing plain ones. Existing promotions and the plain rule/action types are unchanged, and no core service is replaced, so the change is fully backward compatible and requires no action.
Implementation: two generic decorators in
Sylius\Component\Core\Promotionunwrap the current channel's configuration slice and delegate to the standard checker/command:Sylius\Component\Core\Promotion\Checker\Rule\PerChannelRuleCheckerSylius\Component\Core\Promotion\Action\PerChannelPromotionActionCommand
The admin forms use new
ChannelBased*ConfigurationTypeform types built on top ofSylius\Bundle\CoreBundle\Form\Type\ChannelCollectionType. - Rules:
Deprecations
-
Passing a
Sylius\Component\Core\Calculator\ProductVariantPricesCalculatorInterfacedirectly to the following catalog-facing classes is deprecated since Sylius 2.3. ImplementSylius\Component\Core\Calculator\CatalogPricesCalculatorInterfaceinstead, which extendsProductVariantPricesCalculatorInterfacewith no additional methods. It will be required in Sylius 3.0.Affected classes:
Sylius\Bundle\CoreBundle\Twig\PriceExtensionSylius\Bundle\ApiBundle\Serializer\Normalizer\ProductVariantNormalizerSylius\Bundle\ShopBundle\Twig\Component\Product\PriceComponentSylius\Bundle\ShopBundle\Twig\Component\Product\CardComponentSylius\Component\Core\Provider\ProductVariantMap\ProductVariantPriceMapProviderSylius\Component\Core\Provider\ProductVariantMap\ProductVariantOriginalPriceMapProviderSylius\Component\Core\Provider\ProductVariantMap\ProductVariantLowestPriceMapProvider
If you have a custom calculator used for catalog display, make it implement
CatalogPricesCalculatorInterface:use Sylius\Component\Core\Calculator\CatalogPricesCalculatorInterface; final class MyCustomCatalogPriceCalculator implements CatalogPricesCalculatorInterface { // ... }This allows you to decorate catalog display pricing independently from cart/order pricing (
sylius.order_processing.order_prices_recalculator,sylius.filter.promotion.price_range), which remain onProductVariantPricesCalculatorInterface.