Shipping data export environment for Sylius platform applications



BitBag SyliusShippingExportPlugin

Managing shipments in any eCommerce app is something that may be tricky. There are many shipping providers and each has its own API format you might want to use to export shipping data and request the pickup. To make this process more simple and generic, we decided to create an abstract layer for Sylius platform based applications for this purpose. This plugin allows you to write simple API calls and configuration form for specific shipping provider. The workflow is quite simple - configure a proper data that's needed to export a shipment, like access key or pickup hour, book a courier for an order with one click and get shipping label file if any was received from the API. The implementation limits to writing a shipping provider gateway configuration form, one event listener and webservice access layer.

If you are curious about the details of this plugin, read this blog post.


You can order our support on this page.

We work on amazing eCommerce projects on top of Sylius and other great Symfony based solutions, like eZ Platform, Akeneo or Pimcore. Need some help or additional resources for a project? Write us an email on or visit our website! 🚀


We created a demo app with some useful use-cases of the plugin! Visit to take a look at it. The admin can be accessed under link and sylius: sylius credentials.


If you use Sylius 1.4, you might get a compatibility issue for Pagerfanta. Please read this issue in order to proceed with a workaround.

$ composer require bitbag/shipping-export-plugin

Add plugin dependencies to your config/bundles.php file:

return [

    BitBag\SyliusShippingExportPlugin\BitBagSyliusShippingExportPlugin::class => ['all' => true],

Import required config in your config/packages/_sylius.yaml file:

# config/packages/_sylius.yaml


    - { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/config.yml" }

Import routing on top of your config/routes.yaml file:

# config/routes.yaml

    resource: "@BitBagSyliusShippingExportPlugin/Resources/config/routing.yml"
    prefix: /admin


Adding shipping export configuration form

namespace App\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;

final class FrankMartinShippingGatewayType extends AbstractType
    public function buildForm(FormBuilderInterface $builder, array $options): void
            ->add('iban', TextType::class, [
                'label' => 'IBAN',
                'constraints' => [
                    new NotBlank([
                        'message' => 'IBAN number cannot be blank.',
                        'groups' => 'bitbag',
            ->add('address', TextType::class, [
                'label' => 'Address',
                'constraints' => [
                    new NotBlank([
                        'message' => 'Address cannot be blank.',
                        'groups' => 'bitbag',

Service definition

        class: App\Form\Type\FrankMartinShippingGatewayType
            - { name: bitbag.shipping_gateway_configuration_type, type: "frank_martin_shipping_gateway", label: "Transporter Gateway" }

Adding shipping export event listener

namespace App\EventListener;

use BitBag\ShippingExportPlugin\Event\ExportShipmentEvent;

final class FrankMartinShippingExportEventListener
    public function exportShipment(ExportShipmentEvent $event): void
        $shippingExport = $event->getShippingExport();
        $shippingGateway = $shippingExport->getShippingGateway();

        if ('frank_martin_shipping_gateway' !== $shippingGateway->getCode()) {

        if (false) {
            $event->addErrorFlash(); // Add an error notification


        $event->addSuccessFlash(); // Add success notification
        $event->saveShippingLabel("Some label content received from external API", 'pdf'); // Save label
        $event->exportShipment(); // Mark shipment as "Exported"

Service definition

        class: App\EventListener\FrankMartinShippingExportEventListener
            - { name: kernel.event_listener, event: 'bitbag.export_shipment', method: exportShipment }

Plugin parameters

    bitbag.shipping_gateway.validation_groups: ['bitbag']
    bitbag.shipping_labels_path: '%kernel.root_dir%/../shipping_labels'

Available services you can decorate and forms you can extend

$ bin/console debug:container | grep bitbag

Parameters you can override in your parameters.yml(.dist) file

$ bin/console debug:container --parameters | grep bitbag


$ composer install
$ cd tests/Application
$ yarn install
$ yarn run gulp
$ bin/console assets:install public -e test
$ bin/console doctrine:schema:create -e test
$ bin/console server:run -d public -e test
$ shipping-export
$ open http://localhost:8080
$ vendor/bin/behat
$ vendor/bin/phpspec run


Learn more about our contribution workflow on