PHP code example of mohamedhekal / shipbridge-dhl

1. Go to this page and download the library: Download mohamedhekal/shipbridge-dhl 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/ */

    

mohamedhekal / shipbridge-dhl example snippets


use Hekal\ShipBridge\Facades\ShipBridge;
use Hekal\ShipBridge\DTOs\Address;
use Hekal\ShipBridge\DTOs\CreateShipmentRequest;
use Hekal\ShipBridge\DTOs\Parcel;

$shipment = ShipBridge::driver('dhl')->createShipment(new CreateShipmentRequest(
    origin: new Address('المخزن', 'شارع ١', 'القاهرة', 'EG', postalCode: '11511', phone: '01011111111'),
    destination: new Address('العميل', 'شارع النيل', 'الجيزة', 'EG', phone: '01000000000', postalCode: '12611'),
    parcels: [new Parcel(weightKg: 1.2, lengthCm: 10, widthCm: 10, heightCm: 10)],
    reference: 'ORD-42',
));

echo $shipment->trackingNumber;

ShipBridge::driver('dhl')->track($shipment->trackingNumber);
ShipBridge::driver('dhl')->label($shipment->trackingNumber);
ShipBridge::driver('dhl')->createReturn(...);

ShipBridge::driver('dhl')->createShipment(...); // POST /shipments
ShipBridge::driver('dhl')->track('AWB');         // GET /shipments/{id}/tracking
ShipBridge::driver('dhl')->label('AWB');         // documents[] or tracking URL