Download the PHP package elliotjreed/royal-mail-tracking without Composer

On this page you can find all versions of the php package elliotjreed/royal-mail-tracking. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package royal-mail-tracking

Royal Mail Tracking for PHP

Please raise an issue in the GitHub repository if you are able, if not please feel free to contact me.

Pull requests for bug fixes or potential changes are welcome!

Towards the bottom of this readme is a list of some of the event codes and their rough definition.

Usage

PHP 8.1 or above is required.

To install the package via Composer:

Three means of fetching tracking data are available:

Details for each are outlined below, with examples included.

Information about error handling is provided below the Events, Signature, and Summary information (and is worth reading as Summary errors are handled differently to Events and Summary errors).

Instantiation / Setup

Events

The behaviour of the events operation is to provide a history of tracks for a single mail item.

Returns the summary, signature metadata, estimated delivery window and events for a supplied tracking number.

JSON output

Would output the Royal Mail response as JSON:

Signature

JSON output

Would output the Royal Mail tracking response as JSON:

Summary

The behaviour of the summary operation is to allow customers to obtain the latest tracking data for a mail item.

This operation returns the summary of one or more tracking numbers provided in the request.

This operation only allows a maximum of 30 tracking numbers to be provided in the ->setTrackingNumbers() method (eg. ->setTrackingNumbers(['AB0123456789GB', 'CD0123456789GB'])).

JSON output

Would output the Royal Mail response as JSON:

Errors

Errors are thrown as instances of the \ElliotJReed\RoyalMail\Tracking\Exception\RoyalMailError exception.

Further error information can be accessed through the ->getResponse() method on the thrown exception when available.

Potential causes and resolutions can be accessed through ->getErrorResponse()->getErrors() when available.

Fatal Exceptions / Errors

When the response from Royal Mail's API is one which falls outside of their expected responses a \ElliotJReed\RoyalMail\Tracking\Exception\RoyalMailResponseError is thrown.

This would only be thrown if there is a serious outage at Royal Mail's API (for example, a DNS failure).

Technical Exceptions / Errors

Exceptions are thrown for Events, Signature, and Summary requests for application-specific / technical errors by default (eg. invalid API credentials), as instances of the \ElliotJReed\RoyalMail\Tracking\Exception\RoyalMailTechnicalError exception.

Disabling Exceptions

Exceptions for application-specific can be disabled so that errors are returned in the Response object (via ->getResponse()).

This can be useful for example when parsing the result and handling errors in, say, Javascript on the frontend.

To disable exceptions being thrown set $throwExceptionOnTechnicalError to false in the constructor:

Business Exceptions / Errors

Exceptions are thrown for Events and Signature requests for business/tracking number-specific errors by default (eg. invalid tracking number), as instances of the \ElliotJReed\RoyalMail\Tracking\Exception\RoyalMailTrackingError exception.

Events and Signature
Summary

Errors for business/tracking number-specific Summary request errors are returned in the MailPiece object rather than thrown as exceptions (as Summary will return information for multiple tracking numbers).

Because of this, when an error is encountered an exception will only be thrown when it is an application-specific error, and not when the error is related to a particular tracking number. Instead, the error is returned via the Mailpieces object for specific the tracking number.

Disabling Exceptions

Exceptions for business/tracking number-specific for the Events and Signature can be disabled so that errors are returned in the Response object (via ->getResponse()).

To disable exceptions being thrown set $throwExceptionOnTrackingError to false in the constructor:

Summary errors

The Summary call returns information for multiple tracking numbers, some of which may contain errors.

Using in Symfony

To use this library in Symfony, add the following to the services.yaml to have the Events, Signature, and Summary available for autowiring:

Event codes

EVAIP: Sender despatching item.

EVAIE: Sender despatching item.

ASRXS: As requested, if we can't deliver your item, we'll arrange a Redelivery on [X]. If no one's in again, we'll deliver your item to your chosen Safeplace. We'll let you know when it's delivered.

EVAIP: The sender has advised they've despatched your item to us.

EVBAH: We have your item at National Parcel Hub and it's on its way.

EVDAC: We have your item at [X] MC and it's on its way.

EVDAV: We have your item at [X] MC and it's on its way.

EVGMI: Sorry, your item went to [X] DO in error, so we re-routed it immediately. More information will be available as it travels through our network.

EVGPD: Your Item was received by [X] DO on [X] and is now due for delivery today.

EVIAV: Your item has reached [X] MC and will now be sent to your local delivery office.

EVIMC: Your item has reached [X] MC and will now be sent to your local delivery office.

EVIPI: Sorry, your item went to [X] MC in error, so we re-routed it immediately. More information will be available as it travels through our network.

EVKAA: Sorry, we were unable to deliver this item on [X] as the address was inaccessible. We will attempt to deliver your item again on the next working day.

EVKAI: Sorry, we were unable to deliver this item on [X] as it was not possible to identify the delivery address. It will now be returned to the sender.

EVKDN: We delivered your item to your neighbour [X] at [X] on [X].

EVKGA: Sorry, we were unable to deliver this item on [X] as the recipient is no longer at that address. We're returning the item to the sender.

EVKLC: Your item has been delivered to your nominated collection point on [X] and it's now ready for you to collect.

EVKNA: Sorry, we tried to deliver your parcel on [X] but there didn't seem to be anyone in. Please choose an option below.

EVKOP: Your item was delivered on [X].

EVKRF: Sorry, we were unable to deliver this item on [X] as the recipient refused to accept it. It will now be returned to the sender.

EVKSF: Your item was delivered to your Safeplace on [X].

EVKSP: Your item was delivered on [X].

EVKSU: Sorry, we've been unable to deliver your item to your nominated Safeplace today, [X]. Please choose an option below.

EVNAA: Sorry, we were unable to deliver this item on [X] as the address was inaccessible. We will attempt to deliver your item again on the next working day.

EVNAR: Due for Redelivery the Next Working Day.

EVNDA: Sorry, we tried to deliver your parcel on [X] but there didn't seem to be anyone in. Please choose an option below.

EVNDN: Sorry, we were unable to deliver this item on [X]. We'll attempt to deliver it on the next working day. See below for more information.

EVNGA: Sorry, we were unable to deliver this item on [X] as the recipient is no longer at that address. We're returning the item to the sender.

EVNKS: As requested, we're holding this item at [X] DO as part of our Keepsafe service. See below for more information.

EVNMI: Sorry, your item went to [X] DO in error, so we re-routed it immediately. More information will be available as it travels through our network.

EVNOC: Your item was collected from [X] DO on [X].

EVNRF: Sorry, we were unable to deliver this item on [X] as the recipient refused to accept it. It will now be returned to the sender.

EVNRT: We're holding this item at [X] DO. We've received a request not to deliver mail to the property your item is addressed to today. We'll attempt delivery as per the instructions we've received.

EVPLC: Item [X] was collected by the customer from [X] Post Office [X] on [X].

EVRTS: Your item was delivered back to the sender on [X].

RFRXS: As requested, we'll arrange a Redelivery on [X]. If no one's home, we'll deliver your item to your chosen neighbour.

RNRXS: As requested, we'll arrange a Redelivery on [X] to your chosen address.

RORXS: As requested, we'll arrange a Redelivery for your item on [X].

RPRXS: As requested, we'll arrange a Redelivery to your chosen Post Office.

RSRXS: As requested, we'll arrange a Redelivery on [X]. If no one's home, we'll deliver your item to your chosen Safeplace. We'll let you know when it's delivered.

Development

PHP 8.0 or above and Composer is expected to be installed.

Installing Composer

For instructions on how to install Composer visit getcomposer.org.

Installing

After cloning this repository, change into the newly created directory and run:

or if you have installed Composer locally in your current directory:

This will install all dependencies needed for the project.

Henceforth, the rest of this README will assume composer is installed globally (ie. if you are using composer.phar you will need to use composer.phar instead of composer in your terminal / command-line).

Running the Tests

Unit tests

Unit testing in this project is via PHPUnit.

All unit tests can be run by executing:

Debugging

To have PHPUnit stop and report on the first failing test encountered, run:

Code formatting

A standard for code style can be important when working in teams, as it means that less time is spent by developers processing what they are reading (as everything will be consistent).

Code formatting is automated via PHP-CS-Fixer. PHP-CS-Fixer will not format line lengths which do form part of the PSR-2 coding standards so these will product warnings when checked by PHP Code Sniffer.

These can be run by executing:

Running everything

All of the tests can be run by executing:

Outdated dependencies

Checking for outdated Composer dependencies can be performed by executing:

Validating Composer configuration

Checking that the composer.json is valid can be performed by executing:

Running via GNU Make

If GNU Make is installed, you can replace the above composer command prefixes with make.

All of the tests can be run by executing:

Running the tests on a Continuous Integration platform (eg. Github Actions or Travis)

Specific output formats better suited to CI platforms are included as Composer scripts.

To output unit test coverage in text and Clover XML format (which can be used for services such as Coveralls):

To output PHP-CS-Fixer (dry run) and PHPCS results in checkstyle format (which GitHub Actions will use to output a readable format):

Built With

License

This project is licensed under the MIT License - see the LICENCE.md file for details.


All versions of royal-mail-tracking with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
guzzlehttp/guzzle Version ^6.0|^7.0
symfony/property-access Version ^5.0|^6.0|^7.0
symfony/serializer Version ^5.0|^6.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package elliotjreed/royal-mail-tracking contains the following files

Loading the files please wait ....