Welcome to the documentation site of an unofficial PostNL PHP library
These PHP API bindings aim to make it easier to connect to PostNL’s CIF API, used for displaying delivery options, printing shipment labels and retrieving actual shipment statuses.
The goal is to have a simple interface for connecting with either the SOAP or REST API, while still being able to follow the official API documentation.
Abstracts away direct requests to the API, allowing you to focus on the code itself. The object structure is based on the SOAP API.
Can merge PDF labels (both A6 and A4) and automatically handles concurrent requests when necessary, making batch processing a lot easier.
Follows PHP standards, some of them are:
PSR-3 logging. You can log the requests and responses for debugging purposes. More info on the page Logging.
PSR-7 interfaces for requests and responses. Build and process functions are provided for every service so you can create your own mix of batch requests. See the Firstred\PostNL\PostNL::getTimeframesAndNearestLocations method for an example.
PSR-18 HTTP Clients or HTTPlug clients.
Framework agnostic. You can use this library with any framework.
A custom HTTP client interface so you can use the HTTP client of your choice. Using the Guzzle or Symfony HTTP client is strongly recommended. Any HTTPlug client can be used by installing the related packages. See the HTTP Client chapter for more information.
<?php
use Firstred\PostNL\Entity\Timeframe;
use Firstred\PostNL\Entity\Request\GetTimeframes;
$postnl = new PostNL(...);
$timeframes = $postnl->getTimeframes(
(new GetTimeframes())
->setTimeframe([(new Timeframe())
->setCountryCode('NL')
->setStartDate(date('d-m-Y', strtotime('+1 day')))
->setEndDate(date('d-m-Y', strtotime('+14 days')))
->setHouseNr(42)
->setPostalCode('2132WT')
->setSundaySorting(true)
->setOptions(['Daytime', 'Evening'])
])
);
var_dump($timeframes);
Developer Guide
- Overview
- Installation
- Authentication
- Quickstart
- Delivery options
- Send and track shipments
- Barcode webservice
- Labelling webservice
- Shipping webservice
- Confirming webservice
- Shippingstatus webservice
- Current or complete shipping status by barcode
- Multiple current or complete shipping statuses by barcodes
- Current or complete shipping status by reference
- Multiple current or complete shipping statuses by references
- Current status by status code
- Current status by phase code
- Complete status by status code
- Complete status by phase code
- Get a single signature by barcode
- Get multiple signatures by barcodes
- Exception handling
- Formats
- HTTP Client
- Logging
- Advanced usage
- API Reference
- Authors