PHPackages                             smartlabs/sonata-ecommerce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. smartlabs/sonata-ecommerce

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

smartlabs/sonata-ecommerce
==========================

Ecommerce solution for Symfony and Sonata Admin (products, orders, payments, invoices)

4.2.0(1mo ago)01[8 issues](https://github.com/smartlabsAT/sonata-project-ecommerce/issues)MITPHPPHP ^8.3CI passing

Since Feb 20Pushed 1mo agoCompare

[ Source](https://github.com/smartlabsAT/sonata-project-ecommerce)[ Packagist](https://packagist.org/packages/smartlabs/sonata-ecommerce)[ Docs](https://smartlabs.at)[ RSS](/packages/smartlabs-sonata-ecommerce/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (8)Dependencies (90)Versions (21)Used By (0)

Sonata eCommerce Bundle
=======================

[](#sonata-ecommerce-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/1c0a9d297c8ce28d7e1f423e450b739b2e3ea7f1d445838a47840f39a20f3805/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d6172746c6162732f736f6e6174612d65636f6d6d657263652e737667)](https://packagist.org/packages/smartlabs/sonata-ecommerce)[![License](https://camo.githubusercontent.com/cf9dfb7190af4963c31ac15c6156a1004144e15f4a89cccd19147a275c2894b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736d6172746c6162732f736f6e6174612d65636f6d6d657263652e737667)](https://packagist.org/packages/smartlabs/sonata-ecommerce)

eCommerce solution for Symfony, built on Sonata Admin. Products, categories, cart, checkout, orders, invoices, payments, and delivery — all integrated with the Sonata ecosystem.

Background
----------

[](#background)

This bundle is a maintained port of the archived [sonata-project/ecommerce](https://github.com/sonata-project/ecommerce) (v3.5.2, July 2022).

We have been using sonata-project/ecommerce in production for years. When it was archived and left behind by the Symfony ecosystem, we decided to port it to current versions and share it with the community. The functionality and architecture are preserved 1:1 — only changes required for compatibility with current dependency versions have been made.

Requirements
------------

[](#requirements)

- PHP ^8.2
- Symfony 7.4.\*
- Sonata Admin ^4.42
- Doctrine ORM ^3.6 / DBAL ^4.0

Installation
------------

[](#installation)

```
composer require smartlabs/sonata-ecommerce
```

Register the bundles in `config/bundles.php`:

```
return [
    // ... other bundles
    Sonata\ProductBundle\SonataProductBundle::class => ['all' => true],
    Sonata\BasketBundle\SonataBasketBundle::class => ['all' => true],
    Sonata\OrderBundle\SonataOrderBundle::class => ['all' => true],
    Sonata\InvoiceBundle\SonataInvoiceBundle::class => ['all' => true],
    Sonata\CustomerBundle\SonataCustomerBundle::class => ['all' => true],
    Sonata\PaymentBundle\SonataPaymentBundle::class => ['all' => true],
    Sonata\DeliveryBundle\SonataDeliveryBundle::class => ['all' => true],
    Sonata\PriceBundle\SonataPriceBundle::class => ['all' => true],
];
```

Quick Start
-----------

[](#quick-start)

### 1. Create your entities

[](#1-create-your-entities)

The bundle provides abstract `Base*` entities. Create concrete entities in your application:

```
// src/Entity/Product.php
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Sonata\ProductBundle\Entity\BaseProduct;

#[ORM\Entity]
#[ORM\Table(name: 'commerce_product')]
class Product extends BaseProduct
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    protected ?int $id = null;
}
```

Repeat for `Basket`, `BasketElement`, `Order`, `OrderElement`, `Invoice`, `InvoiceElement`, `Customer`, `Address`, `Transaction`, `Delivery`, `Package`, `ProductCategory`, `ProductCollection`.

### 2. Configure the bundles

[](#2-configure-the-bundles)

Create configuration files under `config/packages/` for each sub-bundle (`sonata_product.yaml`, `sonata_basket.yaml`, etc.) to map your entity classes.

### 3. Create the database schema

[](#3-create-the-database-schema)

```
php bin/console doctrine:schema:update --force
```

Architecture
------------

[](#architecture)

### Sub-Bundles

[](#sub-bundles)

BundleNamespacePurposeSonataProductBundle`Sonata\ProductBundle`Products, variants, categories, collectionsSonataBasketBundle`Sonata\BasketBundle`Shopping cartSonataOrderBundle`Sonata\OrderBundle`Orders, checkoutSonataInvoiceBundle`Sonata\InvoiceBundle`InvoicesSonataCustomerBundle`Sonata\CustomerBundle`Customers, addressesSonataPaymentBundle`Sonata\PaymentBundle`Payments, transactionsSonataDeliveryBundle`Sonata\DeliveryBundle`Delivery methodsSonataPriceBundle`Sonata\PriceBundle`Price calculation### Shared Component

[](#shared-component)

`Sonata\Component` contains shared code used across all bundles: interfaces, events, currency handling, payment implementations (PayPal, Ogone, Check, Pass, Debug), transformers, and the base entity manager.

Differences from the Original
-----------------------------

[](#differences-from-the-original)

This bundle is a 1:1 port of the original sonata-project/ecommerce. Only changes required for compatibility with current dependency versions have been made.

### Serializer: Symfony Serializer instead of JMS Serializer

[](#serializer-symfony-serializer-instead-of-jms-serializer)

The original bundle used JMS Serializer handlers (via `Sonata\Form\Serializer\BaseSerializerHandler`) to serialize entities to/from their IDs. This base class was [deprecated in sonata-project/form-extensions 1.13](https://github.com/sonata-project/form-extensions/issues/275)and removed in 2.0.

Since `sonata-project/form-extensions` 2.x no longer provides `BaseSerializerHandler` and JMS Serializer is not a required dependency, the serializer handlers have been reimplemented as Symfony Serializer normalizers:

Original (JMS Serializer)Ported (Symfony Serializer)`Sonata\Form\Serializer\BaseSerializerHandler``Component\Serializer\BaseSerializerNormalizer``BasketBundle\Serializer\BasketSerializerHandler``BasketBundle\Serializer\BasketSerializerNormalizer``CustomerBundle\Serializer\CustomerSerializerHandler``CustomerBundle\Serializer\CustomerSerializerNormalizer``OrderBundle\Serializer\OrderSerializerHandler``OrderBundle\Serializer\OrderSerializerNormalizer``OrderBundle\Serializer\OrderElementSerializerHandler``OrderBundle\Serializer\OrderElementSerializerNormalizer``InvoiceBundle\Serializer\InvoiceSerializerHandler``InvoiceBundle\Serializer\InvoiceSerializerNormalizer``ProductBundle\Serializer\ProductSerializerHandler``ProductBundle\Serializer\ProductSerializerNormalizer`The functionality is identical: entities are serialized to their ID and deserialized back to entity objects via the corresponding manager service.

**Service tag:** `serializer.normalizer` (replaces `jms_serializer.subscribing_handler`)

### Doctrine DBAL: Direct Connection Access via EntityManager

[](#doctrine-dbal-direct-connection-access-via-entitymanager)

The original bundle's manager classes (extending `Sonata\Doctrine\Entity\BaseEntityManager`) used `$this->getConnection()` to access the DBAL connection for raw SQL queries.

Since the port uses its own `AbstractEntityManager` (which does not expose a `getConnection()`method), affected classes use `$this->em->getConnection()` instead. This accesses the Doctrine DBAL connection through the injected `EntityManagerInterface`.

**Affected class:** `ProductBundle\Manager\ProductCategoryManager::getProductCount()`

The functionality is identical — only the access path to the DBAL connection differs. The raw SQL query itself has been updated for DBAL 4.x compatibility:

- `$stmt->execute()` / `$stmt->fetchAll()` → `$connection->executeQuery()` / `->fetchAllAssociative()`
- `$metadata->table['name']` → `$metadata->getTableName()`

### Message Queue: Symfony Messenger instead of SonataNotificationBundle

[](#message-queue-symfony-messenger-instead-of-sonatanotificationbundle)

The original bundle used `sonata-project/notification-bundle` for async order processing after payment (stock updates). SonataNotificationBundle is archived and not compatible with Symfony 7.x.

The consumers have been reimplemented as Symfony Messenger handlers:

Original (SonataNotificationBundle)Ported (Symfony Messenger)`PaymentBundle\Consumer\PaymentProcessOrderConsumer``PaymentBundle\MessageHandler\ProcessOrderHandler``PaymentBundle\Consumer\PaymentProcessOrderElementConsumer``PaymentBundle\MessageHandler\ProcessOrderElementHandler``sonata_payment_order_process` notification type`PaymentBundle\Message\ProcessOrderMessage``sonata_payment_order_element_process` notification type`PaymentBundle\Message\ProcessOrderElementMessage``BackendInterface::createAndPublish()` in `PaymentHandler``MessageBusInterface::dispatch()` in `PaymentHandler`The business logic is identical: after payment processing, a `ProcessOrderMessage` is dispatched. The handler loads the order and transaction, then dispatches a `ProcessOrderElementMessage` for each order element. The element handler decrements product stock when both transaction and order status are `VALIDATED`.

**Optional dependency:** `symfony/messenger` is listed as a `suggest` dependency. When not installed, the bundle works normally — only async stock updates after payment are disabled. Install it with:

```
composer require symfony/messenger
```

To process messages asynchronously, configure a transport in `config/packages/messenger.yaml`:

```
framework:
    messenger:
        transports:
            async: '%env(MESSENGER_TRANSPORT_DSN)%'
        routing:
            'Sonata\PaymentBundle\Message\ProcessOrderMessage': async
            'Sonata\PaymentBundle\Message\ProcessOrderElementMessage': async
```

REST API Security
-----------------

[](#rest-api-security)

The bundle includes optional REST API controllers (via FOSRestBundle) for Products, Baskets, Customers, Addresses, Orders, and Invoices. These controllers do **not** include built-in authentication or authorization — this is by design, matching the original bundle architecture.

**You must secure the API routes via your Symfony firewall.** If you import the API routes, add appropriate access control rules:

```
# config/packages/security.yaml
security:
    firewalls:
        api:
            pattern: ^/api
            stateless: true
            # Configure your auth strategy: JWT, API key, OAuth, etc.
    access_control:
        - { path: ^/api/ecommerce, roles: ROLE_API }
```

**Without firewall configuration, all API CRUD endpoints are publicly accessible.** Only import the API routes if you need them, and always secure them at the firewall level.

Credits
-------

[](#credits)

- [Thomas Rabaix](https://github.com/rande) and the [Sonata Project](https://github.com/sonata-project) contributors for the original ecommerce bundle
- [Christopher Schwarz](https://github.com/smartlabsAT) for the port to Symfony 7 / Sonata Admin 4

License
-------

[](#license)

This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance91

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

9

Last Release

44d ago

PHP version history (2 changes)4.0.0PHP ^8.2

4.0.3PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/950fb06f095a57347af7a3514c81979330a621328d75b6272d02277c34159a6d?d=identicon)[smartlabsAT](/maintainers/smartlabsAT)

---

Top Contributors

[![smartlabsAT](https://avatars.githubusercontent.com/u/47238451?v=4)](https://github.com/smartlabsAT "smartlabsAT (44 commits)")

---

Tags

doctrineecommercepaymentsphpshopping-cartsonatasonata-adminsymfonysymfony-bundlesymfonypaymentshopecommercecartproductsonataorder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/smartlabs-sonata-ecommerce/health.svg)

```
[![Health](https://phpackages.com/badges/smartlabs-sonata-ecommerce/health.svg)](https://phpackages.com/packages/smartlabs-sonata-ecommerce)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
