{"id":13579026,"url":"https://github.com/BitBagCommerce/SyliusShippingExportPlugin","last_synced_at":"2025-04-05T20:32:55.700Z","repository":{"id":22797756,"uuid":"91919974","full_name":"BitBagCommerce/SyliusShippingExportPlugin","owner":"BitBagCommerce","description":"Shipping export management architecture for Sylius based apps.","archived":false,"fork":false,"pushed_at":"2024-04-19T09:13:00.000Z","size":1220,"stargazers_count":27,"open_issues_count":2,"forks_count":27,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-19T09:43:31.057Z","etag":null,"topics":["bitbag","courier","ecommerce","shipments","shipping-providers","sylius","sylius-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BitBagCommerce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-05-20T22:32:21.000Z","updated_at":"2024-08-01T21:20:57.027Z","dependencies_parsed_at":"2023-02-19T05:16:07.593Z","dependency_job_id":"ce286621-d732-4fe2-82d4-665392a107a4","html_url":"https://github.com/BitBagCommerce/SyliusShippingExportPlugin","commit_stats":{"total_commits":221,"total_committers":29,"mean_commits":7.620689655172414,"dds":0.6018099547511313,"last_synced_commit":"b3b329a0cb54980be0bf1c54269eb8afb0c8aacd"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitBagCommerce%2FSyliusShippingExportPlugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitBagCommerce%2FSyliusShippingExportPlugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitBagCommerce%2FSyliusShippingExportPlugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitBagCommerce%2FSyliusShippingExportPlugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BitBagCommerce","download_url":"https://codeload.github.com/BitBagCommerce/SyliusShippingExportPlugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246871285,"owners_count":20847456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitbag","courier","ecommerce","shipments","shipping-providers","sylius","sylius-plugin"],"created_at":"2024-08-01T15:01:35.919Z","updated_at":"2025-04-05T20:32:55.689Z","avatar_url":"https://github.com/BitBagCommerce.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# [![](https://bitbag.io/wp-content/uploads/2021/04/ShippingExportPlugin.png)](https://bitbag.io/contact-us/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=plugins_shipping_export)\n\n# BitBag SyliusShippingExportPlugin\n\n----\n\n[![](https://img.shields.io/packagist/l/bitbag/shipping-export-plugin.svg)](https://packagist.org/packages/bitbag/shipping-export-plugin \"License\") \n[![](https://img.shields.io/packagist/v/bitbag/shipping-export-plugin.svg)](https://packagist.org/packages/bitbag/shipping-export-plugin \"Version\")\n[![](https://img.shields.io/github/actions/workflow/status/BitBagCommerce/SyliusShippingExportPlugin/build.yml?branch=master)](https://github.com/BitBagCommerce/SyliusShippingExportPlugin/actions \"Build status\")\n[![](https://img.shields.io/scrutinizer/quality/g/BitBagCommerce/SyliusShippingExportPlugin.svg)](https://scrutinizer-ci.com/g/BitBagCommerce/SyliusShippingExportPlugin/ \"Scrutinizer\") \n[![](https://poser.pugx.org/bitbag/shipping-export-plugin/downloads)](https://packagist.org/packages/bitbag/shipping-export-plugin \"Total Downloads\")\n[![Slack](https://img.shields.io/badge/community%20chat-slack-FF1493.svg)](http://sylius-devs.slack.com)\n[![Support](https://img.shields.io/badge/support-contact%20author-blue])](https://bitbag.io/contact-us/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=plugins_shipping_export)\n\n\u003cp\u003e\n \u003cimg align=\"left\" src=\"https://sylius.com/assets/badge-approved-by-sylius.png\" width=\"85\"\u003e\n\u003c/p\u003e \n\nWe want to impact many unique eCommerce projects and build our brand recognition worldwide, so we are heavily involved in creating open-source solutions, especially for Sylius. We have already created over 35 extensions, which have been downloaded almost 2 million times.\n\nYou can find more information about our eCommerce services and technologies on our website: https://bitbag.io/. We have also created a unique service dedicated to creating plugins: https://bitbag.io/services/sylius-plugin-development. \n\nDo you like our work? Would you like to join us? Check out the “Career” tab: https://bitbag.io/pl/kariera. \n\n# About us\n\nBitBag is a software house that implements tailor-made eCommerce platforms with the entire infrastructure—from creating eCommerce platforms to implementing PIM and CMS systems to developing custom eCommerce applications, specialist B2B solutions, and migrations from other platforms.\n\nWe actively participate in Sylius's development. We have already completed over 150 projects, cooperating with clients from all over the world, including smaller enterprises and large international companies. We have completed projects for such important brands as **Mytheresa, Foodspring, Planeta Huerto (Carrefour Group), Albeco, Mollie, and ArtNight**.\n\nWe have a 70-person team of experts: business analysts and eCommerce consultants, developers, project managers, and QA testers.\n\n**Our services:**\n* B2B and B2C eCommerce platform implementations\n* Multi-vendor marketplace platform implementations\n* eCommerce migrations\n* Sylius plugin development\n* Sylius consulting\n* Project maintenance and long-term support\n* PIM and CMS implementations\n\n**Some numbers from BitBag regarding Sylius:**\n* 70 experts on board \n* +150 projects delivered on top of Sylius,\n* 30 countries of BitBag’s customers,\n* 7 years in the Sylius ecosystem.\n* +35 plugins created for Sylius\n\n***\n[![](https://bitbag.io/wp-content/uploads/2024/09/badges-sylius.png)](https://bitbag.io/contact-us/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=pluginsshippingexport)\n***\n\n## Table of Content\n\n***\n\n* [Overview](#overview)\n* [Functionalities](#functionalities)\n* [Installation](#installation)\n    * [Requirements](#requirements)\n    * [Usage](#usage)\n    * [Testing](#testing)\n* [Demo](#demo)\n* [License](#license)\n* [Contact and Support](#contact-and-support)\n* [Community](#community)\n\n# Overview\n\n***\n\nManaging 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 simpler and generic, we created an abstract layer for Sylius platform-based applications. This plugin allows you to write simple API calls and configuration forms for specific shipping providers. The workflow is quite simple - configure the 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 a 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 a web service access layer.\n\n# Installation\n\nFor the full installation guide, please go [here](doc/installation.md).\n\n----\n## Requirements\n\nWe work on stable, supported and up-to-date versions of packages. We recommend you to do the same.\n\n| Package       | Version       |\n|---------------|---------------|\n| PHP           | 8.2, 8.3      |\n| sylius/sylius | 2.0.x         |\n| MySQL         | \\\u003e= 8.0       |\n| NodeJS        | \\\u003e=20.x, 22.x |\n\n----\n\n## Usage\n\n### Adding shipping export configuration form\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Form\\Type;\n\nuse Symfony\\Component\\Form\\AbstractType;\nuse Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType;\nuse Symfony\\Component\\Form\\FormBuilderInterface;\nuse Symfony\\Component\\Validator\\Constraints\\NotBlank;\n\nfinal class FrankMartinShippingGatewayType extends AbstractType\n{\n    public function buildForm(FormBuilderInterface $builder, array $options): void\n    {\n        $builder\n            -\u003eadd('iban', TextType::class, [\n                'label' =\u003e 'IBAN',\n                'constraints' =\u003e [\n                    new NotBlank([\n                        'message' =\u003e 'IBAN number cannot be blank.',\n                        'groups' =\u003e 'bitbag',\n                    ]),\n                ],\n            ])\n            -\u003eadd('address', TextType::class, [\n                'label' =\u003e 'Address',\n                'constraints' =\u003e [\n                    new NotBlank([\n                        'message' =\u003e 'Address cannot be blank.',\n                        'groups' =\u003e 'bitbag',\n                    ]),\n                ],\n            ])\n        ;\n    }\n}\n```\n\n#### Service definition\n```yaml\nservices:\n    app.form.type.frank_martin_shipping_gateway:\n        class: App\\Form\\Type\\FrankMartinShippingGatewayType\n        tags:\n            - { name: bitbag.shipping_gateway_configuration_type, type: \"frank_martin_shipping_gateway\", label: \"Transporter Gateway\" }\n```\n\n### Adding shipping export event listener\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App\\EventListener;\n\nuse BitBag\\SyliusShippingExportPlugin\\Entity\\ShippingExportInterface;\nuse Doctrine\\Persistence\\ObjectManager;\nuse Sylius\\Bundle\\ResourceBundle\\Event\\ResourceControllerEvent;\nuse Symfony\\Component\\Filesystem\\Filesystem;\nuse Symfony\\Component\\HttpFoundation\\RequestStack;\nuse Webmozart\\Assert\\Assert;\n\nfinal class FrankMartinShippingExportEventListener\n{\n    /** @var RequestStack */\n    private $requestStack;\n\n    /** @var Filesystem */\n    private $filesystem;\n\n    /** @var ObjectManager */\n    private $shippingExportManager;\n\n    /** @var string */\n    private $shippingLabelsPath;\n\n    public function __construct(\n        RequestStack $requestStack,\n        Filesystem $filesystem,\n        ObjectManager $shippingExportManager,\n        string $shippingLabelsPath\n    ) {\n        $this-\u003erequestStack = $requestStack;\n        $this-\u003efilesystem = $filesystem;\n        $this-\u003eshippingExportManager = $shippingExportManager;\n        $this-\u003eshippingLabelsPath = $shippingLabelsPath;\n    }\n\n    public function exportShipment(ResourceControllerEvent $event): void\n    {\n        /** @var ShippingExportInterface $shippingExport */\n        $shippingExport = $event-\u003egetSubject();\n        Assert::isInstanceOf($shippingExport, ShippingExportInterface::class);\n\n        $shippingGateway = $shippingExport-\u003egetShippingGateway();\n        Assert::notNull($shippingGateway);\n\n        if ('frank_martin_shipping_gateway' !== $shippingGateway-\u003egetCode()) {\n            return;\n        }\n\n        $session = $this-\u003erequestStack-\u003egetSession();\n        $flashBag = $session-\u003egetBag('flashes');\n\n        if (false) {\n            $flashBag-\u003eadd('error', 'bitbag.ui.shipping_export_error'); // Add an error notification\n\n            return;\n        }\n\n        $flashBag-\u003eadd('success', 'bitbag.ui.shipment_data_has_been_exported'); // Add success notification\n        $this-\u003esaveShippingLabel($shippingExport, 'Some label content received from external API', 'pdf'); // Save label\n        $this-\u003emarkShipmentAsExported($shippingExport); // Mark shipment as \"Exported\"\n    }\n\n    public function saveShippingLabel(\n        ShippingExportInterface $shippingExport,\n        string $labelContent,\n        string $labelExtension\n    ): void {\n        $labelPath = $this-\u003eshippingLabelsPath\n            . '/' . $this-\u003egetFilename($shippingExport)\n            . '.' . $labelExtension;\n\n        $this-\u003efilesystem-\u003edumpFile($labelPath, $labelContent);\n        $shippingExport-\u003esetLabelPath($labelPath);\n\n        $this-\u003eshippingExportManager-\u003epersist($shippingExport);\n        $this-\u003eshippingExportManager-\u003eflush();\n    }\n\n    private function getFilename(ShippingExportInterface $shippingExport): string\n    {\n        $shipment = $shippingExport-\u003egetShipment();\n        Assert::notNull($shipment);\n\n        $order = $shipment-\u003egetOrder();\n        Assert::notNull($order);\n\n        $orderNumber = $order-\u003egetNumber();\n\n        $shipmentId = $shipment-\u003egetId();\n\n        return implode(\n            '_',\n            [\n                $shipmentId,\n                preg_replace('~[^A-Za-z0-9]~', '', $orderNumber),\n            ]\n        );\n    }\n\n    private function markShipmentAsExported(ShippingExportInterface $shippingExport): void\n    {\n        $shippingExport-\u003esetState(ShippingExportInterface::STATE_EXPORTED);\n        $shippingExport-\u003esetExportedAt(new \\DateTime());\n\n        $this-\u003eshippingExportManager-\u003epersist($shippingExport);\n        $this-\u003eshippingExportManager-\u003eflush();\n    }\n}\n```\n\n#### Service definition\n```yaml\nservices:\n    app.event_listener.frank_martin_shipping_export:\n        class: App\\EventListener\\FrankMartinShippingExportEventListener\n        arguments:\n            - '@request_stack'\n            - '@filesystem'\n            - '@bitbag.manager.shipping_export'\n            - '%bitbag.shipping_labels_path%'\n        tags:\n            - { name: kernel.event_listener, event: 'bitbag.shipping_export.export_shipment', method: exportShipment }\n```\n\n#### Plugin parameters\n```yaml\nparameters:\n    bitbag.shipping_gateway.validation_groups: ['bitbag']\n    bitbag.shipping_labels_path: '%kernel.project_dir%/shipping_labels'\n```\n\n### Available services you can [decorate](https://symfony.com/doc/current/service_container/service_decoration.html) and forms you can [extend](http://symfony.com/doc/current/form/create_form_type_extension.html)\n```bash\n$ bin/console debug:container | grep bitbag\n```\n\n### Parameters you can override in your parameters.yml(.dist) file\n```bash\n$ bin/console debug:container --parameters | grep bitbag\n```\n\n## Testing\n```bash\n$ composer install\n$ APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon\n$ cd tests/Application\n$ yarn install\n$ yarn run gulp\n$ bin/console assets:install public -e test\n$ bin/console doctrine:schema:create -e test\n$ shipping-export\n$ open http://localhost:8080\n$ vendor/bin/behat\n$ vendor/bin/phpspec run\n$ vendor/bin/phpstan analyse -c phpstan.neon -l max src/\n$ vendor/bin/ecs check src\n```\n# Functionalities\n\nAll main functionalities of the plugin are described [here](https://github.com/BitBagCommerce/SyliusWishlistPlugin/blob/master/doc/functionalities.md).\n\n---- \n# Demo\n\n---\n\nWe created a demo app with some useful use-cases of plugins! Visit http://demo.sylius.com/ to take a look at it.\n\n**If you need an overview of Sylius' capabilities, schedule a consultation with our expert.**\n\n[![](https://bitbag.io/wp-content/uploads/2020/10/button_free_consulatation-1.png)](https://bitbag.io/contact-us/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=plugins_shipping_export)\n\n# Additional resources for developers\n\n---\nTo learn more about our contribution workflow and more, we encourage you to use the following resources:\n* [Sylius Documentation](https://docs.sylius.com/en/latest/)\n* [Sylius Contribution Guide](https://docs.sylius.com/en/latest/contributing/)\n* [Sylius Online Course](https://sylius.com/online-course/)\n* [Sylius Shipping Export Plugin Blog](https://bitbag.io/blog/bitbag-shipping-export-plugin-simple-way-to-control-shipments-in-your-online-store)\n\n# License\n\n---\nThis plugin's source code is completely free and released under the terms of the MIT license.\n\n[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen.)\n\n---\n# Contact and Support\n\nThis open-source plugin was developed to help the Sylius community. If you have any additional questions, would like help with installing or configuring the plugin, or need any assistance with your Sylius project - let us know! **Contact us** or send us an **e-mail to hello@bitbag.io** with your question(s).\n\n[![](https://bitbag.io/wp-content/uploads/2020/10/button-contact.png)](https://bitbag.io/contact-us/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=plugins_shipping_export)\n\n---\n# Community\n\nWe invite you to chat with us \u0026 other users on [Sylius Slack](https://sylius-devs.slack.com/) for online communication.\n\n[![](https://bitbag.io/wp-content/uploads/2024/09/badges-partners.png)](https://bitbag.io/contact-us/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=plugins_shipping_export)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBitBagCommerce%2FSyliusShippingExportPlugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBitBagCommerce%2FSyliusShippingExportPlugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBitBagCommerce%2FSyliusShippingExportPlugin/lists"}