sonnenglas / mydhl-php-sdk
Unofficial PHP SDK for MyDHL REST API (DHL Express)
Installs: 26 315
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 4
Open Issues: 0
Requires
- php: ~8.0
- ext-json: *
- guzzlehttp/guzzle: ~7.1
- ramsey/uuid: ^4.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13.2
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.9.11
- phpstan/phpstan-deprecation-rules: ^1.1.1
- phpstan/phpstan-phpunit: ^1.3.3
- phpstan/phpstan-strict-rules: ^1.4.5
- phpunit/phpunit: ^9.5
README
PHP library for using DHL Express REST API (MyDHL API).
Note: It supports only the latest REST API provided by DHL. No SOAP API support.
Supported services:
Usage:
diff
Retrieve rates
use Sonnenglas\MyDHL\MyDHL; use Sonnenglas\MyDHL\ValueObjects\RateAddress; use Sonnenglas\MyDHL\ValueObjects\Package; $testMode = true; $myDhl = new MyDHL('username', 'password', $testMode); $rateService = $myDhl->getRateService(); $originAddress = new RateAddress( countryCode: 'DE', postalCode: '10117', cityName: 'Berlin', ); $destinationAddress = new RateAddress( countryCode: 'DE', postalCode: '20099', cityName: 'Hamburg', ); $package = new Package( weight: 10, // kg height: 20, // cm length: 10, // cm width: 30, // cm ); $shippingDate = new DateTimeImmutable('2021-01-15 12:00:00'); $rates = $rateService->setAccountNumber('99999999') ->setOriginAddress($originAddress) ->setDestinationAddress($destinationAddress) ->setPlannedShippingDate($shippingDate) ->setPackage($package) ->setNextBusinessDay(false) ->setCustomsDeclarable(false) ->getRates();
All usage examples: