kiora / sylius-mondial-relay-plugin
Mondial Relay pickup point shipping integration for Sylius 2
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 1
Type:sylius-plugin
pkg:composer/kiora/sylius-mondial-relay-plugin
Requires
- php: ^8.2
- endroid/qr-code: ^6.0
- sylius/sylius: ^2.0
- symfony/cache: ^7.0
- symfony/http-client: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- phpstan/phpstan: ^1.12
- phpstan/phpstan-doctrine: ^1.5
- phpstan/phpstan-symfony: ^1.4
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^10.5
- symfony/browser-kit: ^7.0
- symfony/debug-bundle: ^7.0
- symfony/dotenv: ^7.0
- symfony/flex: ^2.4
- symfony/intl: ^7.0
README
A comprehensive Mondial Relay integration plugin for Sylius 2.x, providing pickup point shipping functionality for French and European e-commerce stores.
Features
- πΊοΈ Pickup Point Selection: Interactive widget for customers to choose relay points during checkout
- π¦ Dual API Support:
- REST API v2 (Connect): For shipment creation, label generation with Basic Auth
- SOAP API v1: For relay point search (WSI4_PointRelais_Recherche)
- π« Label & QR Code Generation: Automatic shipping labels with QR codes for drop-off
- π Admin Interface:
- Configuration page for API credentials
- Relay point details in order view
- QR code generation from admin panel
- π Sylius 2 Twig Hooks: Native integration with Sylius 2 hook system
- β‘ Performance: Built-in caching for API responses
- π§ͺ Sandbox Mode: Test integration without affecting production
- π Type Safety: PHP 8.2+ with readonly classes and strict typing
- π Well Documented: Complete API documentation and usage examples
Requirements
- PHP 8.2 or higher
- Sylius 2.0 or higher
- Symfony 7.0 or higher
- MySQL 8.0+ or PostgreSQL 13+
- A valid Mondial Relay merchant account
Installation
1. Install via Composer
composer require kiora/sylius-mondial-relay-plugin
2. Register the Bundle
The bundle is automatically registered via Symfony Flex. If not, add it manually to config/bundles.php:
<?php return [ // ... Kiora\SyliusMondialRelayPlugin\KioraSyliusMondialRelayPlugin::class => ['all' => true], ];
3. Import Routes
Create config/routes/kiora_mondial_relay.yaml:
# Admin routes (configuration, shipment actions) kiora_mondial_relay_admin: resource: '@KioraSyliusMondialRelayPlugin/config/routes/admin.yaml' # Shop routes (relay point search/select during checkout) kiora_mondial_relay_shop: resource: '@KioraSyliusMondialRelayPlugin/config/routes/shop.yaml'
4. Extend Shipment Entity (optional)
To store pickup point selections, extend Sylius Shipment entity with the provided trait:
<?php // src/Entity/Shipping/Shipment.php namespace App\Entity\Shipping; use Doctrine\ORM\Mapping as ORM; use Kiora\SyliusMondialRelayPlugin\Entity\MondialRelayShipmentInterface; use Kiora\SyliusMondialRelayPlugin\Entity\MondialRelayShipmentTrait; use Sylius\Component\Core\Model\Shipment as BaseShipment; #[ORM\Entity] #[ORM\Table(name: 'sylius_shipment')] class Shipment extends BaseShipment implements MondialRelayShipmentInterface { use MondialRelayShipmentTrait; }
Then run migrations:
bin/console doctrine:migrations:diff bin/console doctrine:migrations:migrate
5. Clear Cache
bin/console cache:clear
6. Configure API Credentials
Navigate to Admin > Configuration > Mondial Relay to configure:
- REST API v2 (Connect): API Key, API Secret, Brand ID for shipment creation and labels
- SOAP API v1: Enseigne code and Private Key for relay point search
- Sandbox Mode: Enable/disable test environment
The configuration is stored in config/mondial_relay.json and can be tested directly from the admin interface.
Usage
Quick Start with API Client
The plugin provides a complete HTTP client for interacting with the Mondial Relay API:
<?php use Kiora\SyliusMondialRelayPlugin\Api\Client\MondialRelayApiClientInterface; use Kiora\SyliusMondialRelayPlugin\Api\DTO\RelayPointSearchCriteria; class MyService { public function __construct( private readonly MondialRelayApiClientInterface $apiClient ) {} public function searchRelayPoints(string $postalCode): void { // Search by postal code $criteria = RelayPointSearchCriteria::fromPostalCode( postalCode: $postalCode, countryCode: 'FR', radius: 10, limit: 20 ); $collection = $this->apiClient->findRelayPoints($criteria); foreach ($collection as $relayPoint) { echo sprintf( "%s - %s (%s km)\n", $relayPoint->name, $relayPoint->getFullAddress(), $relayPoint->getDistanceKm() ); } } }
See complete documentation: API Client Documentation
See working examples: docs/examples/basic-usage.php
Testing the Integration
Use the provided Makefile commands for development:
# Install dependencies make install # Run tests make test # Run static analysis make phpstan # Fix code style make cs-fix # Run all quality checks make check
Development
Project Structure
kiora-sylius-mondial-relay-plugin/
βββ config/
β βββ routes/
β β βββ admin.yaml # Admin routes (configuration, shipments)
β β βββ shop.yaml # Shop routes (relay point search/select)
β βββ services.yaml # Service definitions
β βββ twig_hooks.yaml # Sylius 2 Twig Hooks configuration
βββ src/
β βββ Api/
β β βββ Client/
β β β βββ MondialRelayApiClient.php # REST API v2 client
β β β βββ MondialRelayApiClientInterface.php
β β β βββ MondialRelaySoapClient.php # SOAP API v1 client
β β βββ DTO/
β β β βββ RelayPointSearchCriteria.php # Search parameters
β β β βββ RelayPointDTO.php # Relay point data
β β β βββ RelayPointCollection.php # Iterable collection
β β β βββ ...
β β βββ Exception/
β β βββ MondialRelayApiException.php # API exceptions
β βββ Controller/
β β βββ Admin/
β β β βββ ConfigurationController.php # API configuration page
β β β βββ ShipmentController.php # Label/QR code generation
β β βββ Shop/
β β βββ RelayPointController.php # Relay point search/select
β βββ Entity/
β β βββ MondialRelayPickupPoint.php # Pickup point entity
β β βββ MondialRelayShipmentTrait.php # Shipment extension trait
β βββ Service/
β β βββ MondialRelayLabelGenerator.php # Shipping labels
β β βββ MondialRelayQrCodeGenerator.php # QR codes for drop-off
β βββ DependencyInjection/
β β βββ Configuration.php
β β βββ KioraSyliusMondialRelayExtension.php
β βββ KioraSyliusMondialRelayPlugin.php
βββ templates/
β βββ admin/
β β βββ configuration/ # Admin configuration page templates
β β βββ order/show/ # Order detail Mondial Relay info
β βββ shop/
β βββ checkout/ # Relay point selector widget
βββ CHANGELOG.md
βββ composer.json
βββ README.md
Running Tests
composer test
Static Analysis
composer phpstan
Code Style
composer cs-fix
Troubleshooting
API Authentication Errors
If you receive authentication errors:
- Verify your credentials in the Mondial Relay merchant portal
- Ensure you're using the correct environment (sandbox vs production)
- Check that the API secret is properly configured for request signing
Cache Issues
Clear the plugin cache:
bin/console cache:pool:clear kiora_sylius_mondial_relay.cache
Network Timeouts
Increase the HTTP timeout in your configuration:
kiora_sylius_mondial_relay: http: timeout: 30
Documentation
Plugin Documentation
- API Client Guide - Complete HTTP client documentation
- API Client Summary - Implementation details and statistics
- Code Examples - 8 working examples for common use cases
- Changelog - Version history and changes
External Documentation
Support
For bugs, feature requests, or questions:
- GitHub Issues: Create an issue
- Email: support@kiora.tech
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes with clear messages
- Add tests for new functionality
- Submit a pull request
License
This plugin is licensed under the MIT License. See LICENSE for details.
Credits
Developed by Kiora
Built for Sylius, the modern e-commerce framework for PHP.
Note: This plugin requires a valid Mondial Relay merchant account. Visit Mondial Relay Professional to register.