dbx12/yii2-dhl

Connect you Yii2 application with the DHL parcel tracking API

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Type:yii2-extension

1.0.0 2020-09-16 06:55 UTC

This package is auto-updated.

Last update: 2024-05-16 14:59:59 UTC


README

Connect you Yii2 application with the DHL parcel tracking API. This project was created to work with API version 1.1.0.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist dbx12/yii2-dhl "*"

or add

"dbx12/yii2-dhl": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, configure it as component in your config files. You need to register here on the DHL Developer Portal to get an API key for the Shipment Tracking - Unified API. Put the consumer key in your config file as seen below.

return [
    'components' => [
        'dhl' => [
            'class' => \dbx12\dhl_component\DhlComponent::class,
            'consumerKey' => 'consumer-key-here'
        ],
    ],
];

You can than use it as component, for example, if you want to find out about the parcel with the tracking number 00123456789123456789, you would do this:

$shipment = Yii::$app->dhl->getShipment('00123456789123456789');

The return value is basically a \yii\base\Model object, the structure is mostly oriented on the documentation on the documented schema here. Some differences exist due to the inner workings of Yii models.