PHP code example of mohamedhekal / shipbridge-bosta

1. Go to this page and download the library: Download mohamedhekal/shipbridge-bosta 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-bosta 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('bosta')->createShipment(new CreateShipmentRequest(
    origin: new Address('المخزن', 'شارع الصناعة ١', 'Cairo', 'EG', phone: '01011111111'),
    destination: new Address('أحمد علي', '١٢ شارع النيل', 'Giza', 'EG', phone: '01000000000'),
    parcels: [new Parcel(weightKg: 1.2, description: 'ملابس')],
    reference: 'ORD-42',
    metadata: [
        'cod' => 350,              // تحصيل عند الاستلام (جنيه)
        'city_code' => 'EG-02',    // كود مدينة Bosta (الجيزة)
        'zone' => 'الدقي',
        'building_number' => 12,
        'notes' => 'اتصل قبل التسليم',
    ],
));

echo $shipment->trackingNumber; // رقم التتبع من Bosta

ShipBridge::driver('bosta')->track($shipment->trackingNumber);
ShipBridge::driver('bosta')->label($shipment->trackingNumber); // AWB PDF (base64)