PHP code example of ernadoo / mondial-relay-bundle

1. Go to this page and download the library: Download ernadoo/mondial-relay-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ernadoo / mondial-relay-bundle example snippets


return [
    // ...
    Ernadoo\MondialRelayBundle\ErnadooMondialRelayBundle::class => ['all' => true],
];

use Ernadoo\MondialRelay\Contract\MondialRelayClientInterface;
use Ernadoo\MondialRelay\Shipment\Address;
use Ernadoo\MondialRelay\Shipment\Parcel;
use Ernadoo\MondialRelay\Shipment\ShipmentRequest;

class LabelController extends AbstractController
{
    public function __construct(
        private readonly MondialRelayClientInterface $mondialRelay,
    ) {}

    public function print(): Response
    {
        $response = $this->mondialRelay->createShipment(new ShipmentRequest(
            sender:    new Address('FR', '59510', 'Hem', '4 Av. Pinay', 'Erwan', 'Nader'),
            recipient: new Address('FR', '75001', 'Paris', '1 Rue de la Paix', 'Jane', 'Doe'),
            parcels:   [new Parcel(500)],
        ));

        return $this->redirect($response->labelOutput); // download PDF
    }
}