4 min. read
Symfony 2.3 upgrade summary
I'm delighted to announce that Sylius is now using Symfony 2.3. Read the summary of the upgrade - it brings much more than just that!
Symfony 2.3 upgrade summary

Long awaited, Symfony 2.3 upgrade has been merged six days ago and it introduces much more than just vendors update.

Thanks to the improvements done to the framework and Doctrine integration, we
were able to make another step towards top flexibility.

I’d like to thank all the participants for the ideas and suggestions, especially Molchanov Ivan.
He carried out new listener which allows to include default entities in the bundles and extend them easily in your own application.

You can read about this and other features in the summary below.

“Entity” and “Document” classes are gone

With the new compiler passes available, I got rid of all the Entity and
Document classes. From now, no matter which database storage you are using, please extend the Model class directly.

Appropriate mapping will be loaded automatically, turning the model classes into ODM documents or ORM entities, depending on your driver setting.

Customizable models

Thanks to the new Doctrine listener which hooks into the loadClassMetadata
event, we are able to provide default entities in all bundles.

This makes the installation much easier, as you do not have to define new classes,
just to map an ID field and configure it in config.yml.

In case you want to override a model in any bundle, simply extend the
Model class and define only your custom mappings. The listener will
automatically turn the default entities into mapped super classes.

A more detailed guide how to override models can be found in the

It was possible before, but had several disadvantages. We had to keep hacky entities like DefaultCart
or DefaultProduct and Sylius always wanted to create database tables for
them, even if they were not used. Also, overriding core models required
copying some of the mappings, now everything is moved by the framework.

Cart and Order merge

Previously, the Cart and Order model were separate, and we were
performing a transformation at the end of the checkout. Unfortunately, this
introduced a lot of duplications.

SyliusCartBundle now works on top of SyliusSalesBundle. This coupling
is acceptable because sales bundle is only about super-flexible Order
model with items and adjustments (for taxes/discounts/shipping charges). The
cart bundle extends this functionality with adding/removing items logic and

This simplifies a lot of checkout logic in the main application, as well as
the codebase in general.

Documentation should be updated accordingly in the following days.

New shipping engine

The new shipping engine deserves a separate article and it will get one. Below
you can see very general summary of the changes.


Constructing a full Shipment model (with all the items) can be an overhead
when you simply want to calculate a cost of shipping few products.

Our shipping cost calculators (CalculatorInterface) required the
ShipmentInterface as an argument. Currently, any model can be used for the
calculation, only requirement is to implement the new
ShippingSubjectInterface. Obviously, the default shipment interface inherits from it.

The new interface contains several methods which should return the information
about the potential or real shipment. It also allowed us to implement weight
based cost calculators and new rules.

Shipping rules

If you ever integrated our promotions system, you should already be familiar with this concept.

Basically, every Rule model holds a name of the RuleChecker and
appropriate configuration.

Every shipping method can hold a collection of rules. When you want to display
the available shipping methods to the user, a special service goes through
all the methods. It uses the RuleCheckers to validate if given
ShippingMethod is capable of transporting the particular
ShippingSubjectInterface instance.

Each checker can have a configuration schema. It is used to display a form
when creating new ShippingMethod.

It may sound complex, but it is really simple and allows almost unlimited flexibility because you
can implement your own checkers!

A documentation PR has been opened and should be merged soon.

Decoupling Assortment Bundle

Sylius products catalog is inspired by the Spree project and supports product options, variations, attributes and prototypes.
In many cases, you need much less than that and the additional options and
variants engine only complicates your work, when you require only simple
product model with properties.

Thanks to the flexibility of Symfony 2.3, I decoupled the original
SyliusAssortmentBundle into two new bundles – SyliusProductBundle and

The first bundle provides the basic product model with attributes and

The second one works as an extension layer. You simply need to enable it in
the Kernel and you will get options and variants support, without any

I also believe that the names are clearer now. Many people searching for
products catalog were missing the old bundle because of the naming.

Overriding validation got easier

Thanks to the work of Sasa Stamenkovic and
me, all validation mappings and forms in the bundles use “sylius” as the default

Before this change, you were pretty much stuck with the validation rules
shipped with Sylius.

From now on, you can configure the used validation group for each model and
use your own mappings.

A more detailed guide how to override validation can be found in the

Upgrade to the latest phpspec

As you may know, the excellent phpspec2 got out of the
alpha stage and released its beta. This release included some great improvements,
like the new mocking tool, the Prophecy.

Few BC breaks were involved, but I got all the specs updated and we’re now using the phpspec 2.0.0 BETA4.

Final Thoughts

With the Symfony 2.3 upgrade finalized, we can move forward with pending
features. Last week I’ve also done some documentation improvements and implemented checkout events.

Expect another blog post next Friday and I hope you enjoyed this read!

Paweł Jędrzejewski
Self-taught developer and entrepreneur, who has built an entire career and business through Open Source technology. Speaker at international conferences. PHPers meetups co-organizer. Keen on helping other young entrepreneurs and companies who may want to follow a similar path.
More from our blog
Business News Technical 4 min read 28.09.2020
Get ready for global sales & operations with the most advanced payment solution from the famous fintech giant, now available in Sylius out of the box. Read More
Business News 4 min read 14.09.2020
We proudly present to you the latest version of the Sylius eCommerce Platform – 1.8, which comes with a brand new, unified API powered by API Platform, Loyalty points system for Sylius Plus, and as you can probably see, a brand new sylius.com website! Numbers This new release is a… Read More
Business Ecosystem News 4 min read 13.08.2020
Read why the French market leader trusted Sylius in a strategic re-platforming process to get a competitive eCommerce advantage. Read More