PHPackages                             booni3/dhl-express-rest - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. booni3/dhl-express-rest

ActiveLibrary[API Development](/categories/api)

booni3/dhl-express-rest
=======================

DHL Express REST API

0.7.0(1mo ago)34613MITPHPPHP ^7.4|^8.0CI passing

Since Jan 21Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/booni3/dhl-express-rest)[ Packagist](https://packagist.org/packages/booni3/dhl-express-rest)[ Docs](https://github.com/booni3/dhl-express-rest)[ RSS](/packages/booni3-dhl-express-rest/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (6)Versions (23)Used By (0)

DHL Express REST
================

[](#dhl-express-rest)

[![Latest Version on Packagist](https://camo.githubusercontent.com/df6ff0eb00de60d2c6b87566dd4b5d2fb38283539df56b5aba0c0595766a629d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626f6f6e69332f64686c2d657870726573732d726573742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/booni3/dhl-express-rest)

PHP package for the MyDHL Express REST API. The package is hand-written around the existing DTO surface and is tested against the bundled MyDHL API 3.3.1 OpenAPI spec.

Installation
------------

[](#installation)

```
composer require booni3/dhl-express-rest:^0.7
```

Client
------

[](#client)

```
use Booni3\DhlExpressRest\DHL;

$dhl = DHL::make([
    'user' => 'DHLUSER',
    'pass' => 'DHLPASS',
    'sandbox' => true, // false or omit for production
]);
```

The package sends the required `x-version: 3.3.1` header on every request.

- Sandbox base URI: `https://express.api.dhl.com/mydhlapi/test/`
- Production base URI: `https://express.api.dhl.com/mydhlapi/`

Creating a Shipment
-------------------

[](#creating-a-shipment)

```
use Booni3\DhlExpressRest\DHL;
use Booni3\DhlExpressRest\DTO\Address;
use Booni3\DhlExpressRest\DTO\Package;
use Booni3\DhlExpressRest\DTO\ShipmentCreator;

$shipment = new ShipmentCreator();
$shipment->setShipperAccountNumber('123456789');
$shipment->setProductCode('N');
$shipment->setShipper(
    (new Address(
        'John Smith',
        '21 Apple Drive',
        '',
        '',
        'Malmesbury',
        'SN16 4TB',
        'GB',
        'business',
        'My Awesome Company',
        '07111111111',
        'sender@example.com'
    ))
        ->addVat('GB1234')
        ->addEORI('GB1234')
);
$shipment->setReceiver(new Address(
    'Helen Jones',
    '4 Example Drive',
    '',
    '',
    'London',
    'E14 8DW',
    'GB',
    'direct_consumer',
    '-',
    '07111111112',
    'receiver@example.com'
));
$shipment->addReference('123456-custom-ref');
$shipment->addPackage(new Package(12.5, 20, 10, 10, 'Jumpers', 'order-ref-1244'));

$response = $dhl->shipments()->create($shipment);

$response->trackingNumber; // shipment tracking number
$response->trackingUrl;    // DHL tracking URL
$response->labelData();    // decoded label data
```

`Address` requires a DHL `typeCode`: `business`, `direct_consumer`, `government`, `other`, `private`, or `reseller`. The optional trailing constructor arguments are `countyName` and `provinceCode`.

Customs, DDP, and IOSS
----------------------

[](#customs-ddp-and-ioss)

For customs-declarable shipments, set the customs flag, description, invoice, export declaration, and line items. DDP and IOSS are set explicitly.

```
use Booni3\DhlExpressRest\DTO\LineItem;
use Carbon\Carbon;

$shipment->setConsignmentDescription('Table legs');
$shipment->setCustomsDeclarable(true, true); // customs declarable, paperless trade

// DDP: adds value-added service DD and the duties/taxes billing account.
$shipment->setTermsDDP('123456789');

// IOSS: defaults to DAP unless you pass a different incoterm as the third argument.
// $shipment->setTermsIOSS('IM1234567890', 'GB');

$shipment->setInvoice('PS-1234', Carbon::now(), 'Adam Lambert');
$shipment->setExportDeclaration('sale', 'permanent', 'GBP');
$shipment->addExportLineItem(new LineItem(
    'Black steel table legs',
    84.95,
    1,
    9403999045,
    'GB',
    9.1
));
```

Rates
-----

[](#rates)

```
$rates = $dhl->rates()->retrieve($shipment);

$rates->cheapestProduct();
$rates->fastestProduct();
$rates->shortestTransitDaysAndCheapest();
```

When a declared value is set on the `ShipmentCreator`, rates use that value and currency. Existing callers that do not set a declared value keep the previous default of `100 GBP`.

Landed Cost
-----------

[](#landed-cost)

The landed-cost endpoint accepts the MyDHL landed-cost request payload as an array and returns a `LandedCostResponse`.

```
$landedCost = $dhl->landedCost()->retrieve($payload);

$landedCost->warnings;
$landedCost->landedCostProducts();
$landedCost->firstLandedCostProduct();
```

`firstLandedCostProduct()` summarises the selected DHL product with `totalPrice`, `priceCurrency`, `duty`, `tax`, `fee`, the Duty Tax Paid service row when DHL returns one, and the raw item breakdowns.

Tracking
--------

[](#tracking)

```
$tracking = $dhl->tracking()->single('1234567890');

$multiTracking = $dhl->tracking()->multi([
    '1234567890',
    '0987654321',
]);
```

`Tracking::multi()` accepts 1 to 200 tracking numbers and sends repeated `shipmentTrackingNumber` query parameters as required by the MyDHL spec.

Testing
-------

[](#testing)

```
composer test
```

The test suite uses Guzzle mock handlers only; it does not make live DHL calls. Contract tests validate built request payloads against `docs/dpdhl-express-api-3.3.1.yaml`, after sanitising DHL's tab-containing YAML through `bin/build-spec.php`.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Adam](https://github.com/booni3)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Other Resources
---------------

[](#other-resources)

- [Postman Collection](https://www.getpostman.com/collections/60a3a325988c8b0fcc17)
- [Brexit Export Guide](https://dhlguide.co.uk/wp-content/uploads/2020/09/DHL_BREXIT-BREXIT_ESS_GUIDE-1.pdf)
- [Supermodel Docs](https://supermodel.io/logistics/express)

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~95 days

Recently: every ~415 days

Total

22

Last Release

41d ago

PHP version history (2 changes)0.1PHP ^7.4

0.6PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f64fba4a9927986d1c9605cc039c743624ba7d3e5588bd18ddeae49e66d86e9?d=identicon)[booni3](/maintainers/booni3)

---

Top Contributors

[![booni3](https://avatars.githubusercontent.com/u/20134485?v=4)](https://github.com/booni3 "booni3 (45 commits)")

---

Tags

booni3dhl-express-rest

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/booni3-dhl-express-rest/health.svg)

```
[![Health](https://phpackages.com/badges/booni3-dhl-express-rest/health.svg)](https://phpackages.com/packages/booni3-dhl-express-rest)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.9k556.2M21.4k](/packages/laravel-framework)[statamic/cms

The Statamic CMS Core Package

4.9k3.8M1.2k](/packages/statamic-cms)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[lion/bundle

Lion-framework configuration and initialization package

132.4k5](/packages/lion-bundle)[files.com/files-php-sdk

Files.com PHP SDK

2482.9k](/packages/filescom-files-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
