PHP code example of beziworld / laravel-dhl-parcel

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

    

beziworld / laravel-dhl-parcel example snippets


use Beziworld\DhlParcel\Data\Address;
use Beziworld\DhlParcel\Data\Piece;
use Beziworld\DhlParcel\Data\Shipment;
use Beziworld\DhlParcel\Facades\DhlParcel;

$created = DhlParcel::createShipment(new Shipment(
    receiver: new Address('Anna Kowalska', '30-001', 'Kraków', 'Długa', '5', apartmentNumber: '3',
        contactPhone: '600700800', contactEmail: '[email protected]', addressType: 'C'),
    pieces: [new Piece(weight: 2.5, length: 30, width: 20, height: 10)],
    content: 'Books',
    reference: 'ORDER-1',
    codAmount: 149.99,              // insured for the same amount unless insuredValue is given
    predeliveryInformation: true,
));

$label = DhlParcel::label($created->shipmentId);   // Label: content (binary), mimeType, fileName
Storage::put("labels/{$created->shipmentId}.pdf", $label->content);

$orders = DhlParcel::bookCourier('2026-11-05', '10:00', '15:00', [$created->shipmentId]);
DhlParcel::cancelCourierBooking($orders);

$tracking = DhlParcel::tracking($created->shipmentId);
$tracking->latest()?->status;      // DHL status code
$tracking->latest()?->description;
$tracking->isDelivered();          // true once DHL records who received the shipment

DhlParcel::servicePoints('30-001', 'Kraków', radius: 3);   // list<ServicePoint>: sap, address, hours
DhlParcel::postalCodeServices('30-001', '2026-11-05');      // pickup windows, express availability
DhlParcel::deleteShipments([$created->shipmentId]);         // ['9000...' => ['result' => true, 'error' => null]]
DhlParcel::call('getVersion');   // any operation