Download the PHP package daniellarusso/dhl-php-sdk without Composer
On this page you can find all versions of the php package daniellarusso/dhl-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package dhl-php-sdk
DHL PHP SDK
This unofficial library is wrapping some functions of the DHL SOAP API in order to easy create/delete shipments and labels.
Please note, that this is a fork of Petschko/DHL-PHP-SDK
Installation
You can use Composer to install the package to your project:
The classes are then added to the autoloader automatically.
Requirements
- You need a DHL developer account and - as long as you want to use the API in production systems - a DHL Intraship Account.
- PHP-SOAP-Client installed + enabled on your Server
Compatibility
This Project is written for the DHL-SOAP-API Version 2 or higher.
It barely supports Version 1, feel free to complete the missing functions for Version 1. They are named usually {functionname}_v1
. They are also marked with "todo" if they are not implemented
I can't find a Documentation for Version 1 anymore, so its hard to implement them properly...
Usage
-
You need to include the SDK by requiring the
\DanielLarusso\DHL\BusinessShipment.php
-File, it requires the rest for you. - You need to setup your DHL-Credentials:
TEST-Credentials:
LIVE-Credentials
You've set all of the Required Information so far. Now you can Perform several Actions.
Create a Shipment
Please note, that you need the \DanielLarusso\DHL\Credentials
Object with Valid Login-Information for that.
Classes used:
\DanielLarusso\DHL\Credentials
(Req) - Login Information\DanielLarusso\DHL\ShipmentDetails
(Req) - Details of the Shipment\DanielLarusso\DHL\Sender
(Req) - Sender Details\DanielLarusso\DHL\SendPerson
(Parent)\DanielLarusso\DHL\Address
(Parent)
\DanielLarusso\DHL\ReturnReceiver
(Optional) - Return Receiver Details\DanielLarusso\DHL\SendPerson
(Parent)\DanielLarusso\DHL\Address
(Parent)
\DanielLarusso\DHL\Service
(Optional) - Service Details (Many Configurations for the Shipment)\DanielLarusso\DHL\IdentCheck
(Very Optional) - Ident-Check Details, only needed if turned on in Service\DanielLarusso\DHL\BankData
(Optional) - Bank-Information\DanielLarusso\DHL\BusinessShipment
(Req) - Manages all Actions + Information\DanielLarusso\DHL\Version
(Parent)
\DanielLarusso\DHL\Response
(Req|Auto) - Response Information\DanielLarusso\DHL\Version
(Parent)
One of them:
\DanielLarusso\DHL\Receiver
(Req) - Receiver Details\DanielLarusso\DHL\SendPerson
(Parent)\DanielLarusso\DHL\Address
(Parent)
\DanielLarusso\DHL\Filial
(Optional) - Receiver-Details (Post-Filial)\DanielLarusso\DHL\Receiver
(Req|Parent) - Receiver Details\DanielLarusso\DHL\SendPerson
(Parent)\DanielLarusso\DHL\Address
(Parent)
\DanielLarusso\DHL\PackStation
(Optional) - Receiver-Details (Pack-Station)\DanielLarusso\DHL\Receiver
(Req|Parent) - Receiver Details\DanielLarusso\DHL\SendPerson
(Parent)\DanielLarusso\DHL\Address
(Parent)
How to create
\DanielLarusso\DHL\ShipmentDetails Object
You need to setup the Shipment-Details for your Shipment (like Size/Weight etc). You can do that with the \DanielLarusso\DHL\ShipmentDetails
Object.
You can setup details for that, if you need. If you don't set them, it use the default values (This Part is Optional)
\DanielLarusso\DHL\Sender, \DanielLarusso\DHL\Receiver + \DanielLarusso\DHL\ReturnReceiver Object(s)
Now you have to create a Sender and a Receiver. They are similar to set, just the XML creation is different so you have to use different Objects for that.
If you want to lookup all values, you can search trough the \DanielLarusso\DHL\SendPerson
+ \DanielLarusso\DHL\Address
Classes.
Lets start with the Sender, in the most cases you =). Create a \DanielLarusso\DHL\Sender
Object:
Setup all Required Information
You can also add more Information, but they are Optional:
This was the sender Object, you can set all the same Information with the \DanielLarusso\DHL\Receiver
+ \DanielLarusso\DHL\ReturnReceiver
Class.
Note: You can also use \DanielLarusso\DHL\PackStation
or \DanielLarusso\DHL\Filial
instead of \DanielLarusso\DHL\Receiver
.
Please note, that they need some extra information.
You don't need to create the \DanielLarusso\DHL\ReturnReceiver
Object if you don't want a return Label.
\DanielLarusso\DHL\Service Object
You can also setup more details for your Shipment by using the \DanielLarusso\DHL\Service
Object. It's an optional Object but may you should look, what you can set to this Object.
I'll not explain the Service-Object because there are too many settings. Please look into the Service-PHP-File by yourself. The fields are well documented.
\DanielLarusso\DHL\BankData Object
You can also use the \DanielLarusso\DHL\BankData
Object. Bank data can be provided for different purposes. E.g. if COD is booked as service, bank data must be provided by DHL customer (mandatory server logic). The collected money will be transferred to specified bank account.
You can look to the PHP-File of the \DanielLarusso\DHL\BankData
-Object, and checkout what you can set there. I will not explain it here.
\DanielLarusso\DHL\BusinessShipment Object
Finally you can add all together. You have to create the \DanielLarusso\DHL\BusinessShipment
Object
If you want to use a specific WSDL-File (or remote), you can set it: (Else you don't need this part)
Here you can add the previous created classes:
``
Now you can set how the Label should get returned and some other stuff:
Create the Request
All set? Fine, now you can finally made the Create-Shipment-Order-Request. Save the Response to a var ``
Handling the response
First you have to check if the Value is not false
You can get several Information from the \DanielLarusso\DHL\Response
Object. Please have a look down where I describe the \DanielLarusso\DHL\Response
Class.
Delete a Shipment
Please note, that you need the \DanielLarusso\DHL\Credentials
Object with Valid Login-Information for that.
You also need the Shipment-Number, from the Shipment, that you want to cancel/delete.
Classes used
\DanielLarusso\DHL\Credentials
(Req) - Login Information\DanielLarusso\DHL\BusinessShipment
(Req) - Manages all Actions + Information\DanielLarusso\DHL\Version
(Parent)
\DanielLarusso\DHL\Response
(Req|Auto) - Response Information\DanielLarusso\DHL\Version
(Parent)
How to create
Deleting a Shipment is not very hard it just work like this:
Same like when creating a Shipment-Order, the Response is false
if the Request failed.
For more Information about the Response, look down where I describe the \DanielLarusso\DHL\Response
Class.
Re-Get a Label
Please note, that you need the \DanielLarusso\DHL\Credentials
Object with Valid Login-Information for that.
You also need the Shipment-Number, from the Shipment, where you want to Re-Get a Label.
Classes used
\DanielLarusso\DHL\Credentials
(Req) - Login Information\DanielLarusso\DHL\BusinessShipment
(Req) - Manages all Actions + Information\DanielLarusso\DHL\Version
(Parent)
\DanielLarusso\DHL\Response
(Req|Auto) - Response Information\DanielLarusso\DHL\Version
(Parent)
How to create
Same like deleting, re-get a Label is not this hard. You can simply re-get a label:
If the request failed, you get false
as usual else a \DanielLarusso\DHL\Response
Object.
DoManifest
Please note, that you need the \DanielLarusso\DHL\Credentials
Object with Valid Login-Information for that.
You also need the Shipment-Number for the Manifest (If you need it, you will know how to use this).
I personally don't know for what is this for, but it works!
Classes used
\DanielLarusso\DHL\Credentials
(Req) - Login Information\DanielLarusso\DHL\BusinessShipment
(Req) - Manages all Actions + Information\DanielLarusso\DHL\Version
(Parent)
\DanielLarusso\DHL\Response
(Req|Auto) - Response Information\DanielLarusso\DHL\Version
(Parent)
How to create
It works like deleting a Shipment:
If the request failed, you get false
else a \DanielLarusso\DHL\Response
Object.
\DanielLarusso\DHL\Response Object
If you get a Response that is not false
, you have to mess with the \DanielLarusso\DHL\Response
Object.
This Object helps you, to get easier to your Goal. You can easily get the Values you need by using the getters. (IDEs will detect them automatic)
I will explain which values you can get from the Response-Object
If a value is not set you get usually null
as result. Not every Action fills out all of these values!
You can also take a look at the Class Constance's, they are helping you to identify the Status-Codes:
That's all so far
Contact
- You can E-Mail me if you have Questions or whatever (No Bug-Reporting please!): [email protected]
- You can Report Bugs here in the "Issue"-Section of the Project.
- Of course you can also ask any stuff there, feel free for that!
- If you want to use German, you can do it. Please keep in mind that not everybody can speak German, so it's better to use english =)