clemenger's avatar

Integrating Sylius components, the data mapper pattern and doctrine

Im struggling with certain decisions regarding the integration of Sylius Components into a Laravel e-commerce package ecosystem. As this would cut our development time massively and leverage a cross community solution. Issues with this approach:

  • Sylius is based off Doctrine ORM that uses the "data mapper" pattern. Unlike Laravel with uses Eloquent and an "active record" pattern

  • No matter what is stated, Sylius components are essentially tied to Doctrine because it is the only (real) option for the data mapper pattern in PHP.

  • Would we alienate most of the Laravel community by using Doctrine? Thus loosing most of our user base and the project never really taking off?

  • If we ditch doctrine, and the data mapper pattern, there is not much use for Sylius components apart from a little bit of a guide designing our own components on the active record pattern.

  • maybe there is another way that we could integrate sylius components, with their plain old PHP models that I'm just not seeing???

your thoughts...?

0 likes
8 replies
thepsion5's avatar

I wouldn't be turned off by providing Doctrine models as long as you didn't force us to use annotations. ;)

Especially if you provided a set of repository classes (which I feel a lot of Laravel users are familiar with) to work with vs. just Doctrine's entity manager class.

0xMatt's avatar

Sylius is a modern e-commerce solution for built specifically for Symfony2, it's not just Doctrine you'll be having issues with, it's the entire collection of bundles.

You are asking for a lot of work and heart ache trying to convert it to laravel. Instead, if you like their core principals, try to replicate their ideals into your own laravel application specifically crafted for laravel rather than do something I doubt can even be achieved. Plus, sylius is in heavy development, and will change a bit over time according to their road map.

Eliard's avatar

Active record isn't a pattern. It's an anti-pattern :-P

2 likes
johnathanmdell's avatar

I would have to go with @0xMatt on this one, Sylius as great as it is was created for and with Symfony in mind.

Purely based on that I'm building my own Laravel ecomm packages as Sylius just does not fit into the Laravel scope for me.

clemenger's avatar

@0xMatt @41eight Actually Sylius has been architectured with framework agnostic PHP composer packages (they have called these components), along with with Symfony packages (they term bundles) that integrate each of these agnostic packages into that framework.

e.g

...

...

As you can see, there has been allot of work by the Sylius team in making sure there are no hard dependancies on Symfony or Doctrine (I do actually debate this one). If you look at an issue I raised a week ago Separation of ORM layers. you will see they are very keen to foster alternate projects based off their agnostic packages.

Also the initial drive for separating out these concerns was initiated by an earlier issue I raised, around a year ago, with their dev team.

Basically I see so many advantages to a cross framework e-commerce effort. Their are quite substantial advantages to Doctrine's data mapper pattern. The only issue that I have with this is alienating our Laravel user base by not using Eloquent ORM

That is what I want to discuss here and get a handle on.

OzzyBoy's avatar

Is it possible to integrate this components to Laravel ?

Please or to participate in this conversation.