- Installation
- Installation without composer
- Requirements
- Quick start and examples
- Available Methods
- Contribute
Please, star this repository if you use this repository. ⭐
This SDK uses composer.
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
For more information on how to use/install composer, please visit: https://github.com/composer/composer
To install the MyParcel SDK into your project, simply
$ composer require myparcelnl/sdk
If you don't have experience with composer, it is possible to use the SDK without using composer.
You can download the zip on the projects releases page.
- Download the package zip (SDKvx.x.x.zip).
- Unzip the contents of the zip, and upload the vendor directory to your server.
- In your project, require the file vendor/autoload.php
- You can now use the SDK in your project
The MyParcel SDK works on php versions 5.6 and 7.0 Also the php curl extension needs to be installed.
$myParcelAPI = new MyParcelAPI();
$consignment = (new MyParcelConsignmentRepository())
->setApiKey('api_key_from_MyParcel_backoffice')
->setCountry('NL')
->setPerson('Piet Hier')
->setCompany('Piet BV')
->setFullStreet('Plein 1945 55b')
->setPostalCode('2231JE')
->setCity('Amsterdam')
->setEmail('[email protected]');
$myParcelAPI
->addConsignment($consignment)
->setPdfOfLabels()
->downloadPdfOfLabels();
Please run vendor/bin/phpunit --bootstrap vendor/autoload.php tests/
to test the application
$myParcelAPI = new MyParcelAPI();
$consignment = (new MyParcelConsignmentRepository())
->setApiKey('api_key_from_MyParcel_backoffice')
->setCountry('NL')
->setPerson('Piet Hier')
->setCompany('Piet BV')
->setFullStreet('Plein 1945 55b')
->setPostalCode('2231JE')
->setPackageType(1)
->setCity('Amsterdam')
->setEmail('[email protected]')
->setPhone('+31 (0)634213465')
->setLargeFormat(false)
->setOnlyRecipient(false)
->setSignature(false)
->setReturn(false)
->setInsurance(false)
->setLabelDescription('Order 10034');
$myParcelAPI
->addConsignment($consignment)
$myParcelAPI->createConcepts();
$myParcelAPI->setPdfOfLabels();
$myParcelAPI->downloadPdfOfLabels();
$myParcelAPI
->setLinkOfLabels()
->getLinkOfLabels()
After setPdfOfLabels()
, setLinkOfLabels()
and createConcepts()
you can save the api id to your database. With this id you can easily retrieve the latest status.
$consignment->getApiId();
The barcode is available after setPdfOfLabels()
and setLinkOfLabels()
$consignment->getBarcode();
After setPdfOfLabels()
, setLinkOfLabels()
and createConcepts()
you can get the status.
$consignment->getStatus();
To create multiple consignments or get one pdf with multiple consignments, set multiple consignments. It's faster and cleaner.
$myParcelAPI = new MyParcelAPI();
foreach ($yourShipments as $shipment) {
(...) // Set $consignment
$myParcelAPI
->addConsignment($consignment)
}
In a new request, you can get al the data again.
$consignment = (new MyParcelConsignmentRepository())
->setApiKey('api_key_from_MyParcel_backoffice')
->setApiId(205670);
$myParcelAPI
->addConsignment($consignment)
->setLatestData();
$consignment = $myParcelAPI
->getOneConsignment();
$status = $consignment->getStatus();
$barcode = $consignment->getBarcode();
- Check for open issues or open a new issue to start a discussion around a bug or feature.
- Fork the repository on GitHub to start making your changes.
- Write one or more tests for the new feature or that expose the bug.
- Make code changes to implement the feature or fix the bug.
- Send a pull request to get your changes merged and published.