laravel-dhl-parcel maintained by beziworld
Laravel DHL Parcel
DHL Parcel Polska DHL24 WebAPI2 client for Laravel:
- shipments (domestic, express 9/12, evening, service point, international) with COD, insurance and extra services
- labels (PDF for label printers or A4, ZPL 203/300 dpi), customs documents
- courier booking and cancellation, shipment deletion
- tracking, service points, postal code services and prices
- SOAP without
ext-soap: requests go through the Laravel HTTP client, so they can be faked in tests
Installation
composer require beziworld/laravel-dhl-parcel
php artisan vendor:publish --tag=dhl-parcel-config # optional
DHL_PARCEL_USERNAME=... # WebAPI login issued by DHL
DHL_PARCEL_PASSWORD=...
DHL_PARCEL_ACCOUNT_NUMBER=6000000 # SAP number of the paying account
DHL_PARCEL_SANDBOX=false # true = sandbox.dhl24.com.pl (separate credentials)
DHL_PARCEL_LABEL_TYPE=BLP # BLP | LBLP (A4) | ZBLP | ZBLP300 | LP
DHL_PARCEL_SHIPPER_NAME="ACME Sp. z o.o."
DHL_PARCEL_SHIPPER_POSTAL_CODE=00-001
DHL_PARCEL_SHIPPER_CITY=Warszawa
DHL_PARCEL_SHIPPER_STREET=Prosta
DHL_PARCEL_SHIPPER_HOUSE_NUMBER=1
DHL_PARCEL_SHIPPER_PHONE=500600700
DHL_PARCEL_SHIPPER_EMAIL=shop@acme.pl
Access to WebAPI2 is granted by DHL Parcel Polska on request (DHL24 contact form, "WebAPI - uzyskanie dostępu").
Create a shipment and print the label
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: 'anna@example.com', 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);
Products: AH (domestic, default), 09, 12, DW (evening), SP (service point, with servicePointAccountNumber),
EK (Connect), PI (International), PR (Premium). Other ServiceDefinition flags go to extraServices, for
example ['deliveryOnSaturday' => true]. createShipments() accepts any number of shipments and sends them in calls of
three, the DHL limit.
Courier, tracking and more
$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
Errors
DHL reports errors as SOAP faults with a readable message, thrown as ApiException (operation(), faultCode(),
httpStatus()). Connection failures are thrown as ApiException too, and missing credentials as
InvalidConfiguration. Shipment creation is never retried automatically.
Development
composer install
composer ci # pint --test, phpstan (level 8), pest
Author
Created and maintained by Kamil Ćwiertnia, beziworld.eu.
- E-mail: biuro@beziworld.eu
- Issues: GitHub issues
Need a shipping integration for your shop? Get in touch through beziworld.eu.
Other packages by the author
laravel-inpost · laravel-dpd · laravel-orlen-paczka · laravel-furgonetka · laravel-apaczka
License
MIT. See LICENSE.md. This package is not affiliated with DHL.