2017 © Pedro Peláez
 

library php-postcodes

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

image

rapidwebltd/php-postcodes

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

  • Monday, April 16, 2018
  • by DivineOmega
  • Repository
  • 5 Watchers
  • 1 Stars
  • 670 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 15 Versions
  • 3 % Grown

The README.md

PHP Postcodes

Build Status Coverage Status StyleCI Packagist, (*1)

This library handles various UK postcode related tasks., (*2)

Features

  • Address lookup by postcode
  • Postcode validation
  • Generate valid UK postcodes
  • Get a postcode's outward and inward codes

Installation

To install, just run the following composer command., (*3)

composer require rapidwebltd/php-postcodes, (*4)

Setup

Postcode Lookup Services

Using some of the data retrieval features provided by this library requires a postcode lookup service. It currently supports the following postcode lookup services., (*5)

  • Ideal Postcodes - https://ideal-postcodes.co.uk
  • Postcode Anywhere (PCA Predict) - https://www.pcapredict.com/

Sign up at the respective website if you need to use these features., (*6)

You can then use the following code to get an appropriate postcode lookup service object., (*7)

$postcodeLookupService = new \RapidWeb\Postcodes\Objects\IdealPostcodes('API_KEY');
// OR
$postcodeLookupService = new \RapidWeb\Postcodes\Objects\PostcodeAnywhere('API_KEY');

Usage

Get addresses by postcode

To retrieve the addresses associated with a UK postcode, just pass it to the method shown below. You will receive an array of address objects, appropriately split by their address lines and other details., (*8)

$addresses = $postcodeLookupService->getAddressesByPostcode('ST163DP');

Validate postcode

You can validate a UK postcode is correct using the Validator utility class. An example of how to do so is shown below., (*9)

$validated = \RapidWeb\Postcodes\Utils\Validator::validatePostcode('ST163DP');

Please note that the postcode validation is case insensitive., (*10)

Generate postcode

This library allows you generate a random, valid UK postcode. This makes use of the Generator utility class, as shown below., (*11)

$postcode = \RapidWeb\Postcodes\Utils\Generator::generatePostcode();

Get outward and inward codes

The first part of the Postcode eg PO1 is called the outward code as it identifies the town or district to which the letter is to be sent for further sorting. The second part of the postcode eg 1EB is called the inward code., (*12)

$outwardCode = \RapidWeb\Postcodes\Utils\Tokenizer::outward('ST163JR'); // Returns ST16
$inwardCode = \RapidWeb\Postcodes\Utils\Tokenizer::inward('ST163JR'); // Returns 3JR

The Versions

16/04 2018

dev-master

9999999-dev https://github.com/rapidwebltd/php-postcodes

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

  Sources   Download

LGPL3 LGPL-3.0-only

The Requires

 

The Development Requires

php postcodes php library php postcodes library php postcodes

16/04 2018

v2.2.0

2.2.0.0 https://github.com/rapidwebltd/php-postcodes

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

php postcodes php library php postcodes library php postcodes

09/03 2018

v2.1.3

2.1.3.0 https://github.com/rapidwebltd/php-postcodes

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

php postcodes php library php postcodes library php postcodes

09/03 2018

dev-analysis-zEdEMO

dev-analysis-zEdEMO https://github.com/rapidwebltd/php-postcodes

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

php postcodes php library php postcodes library php postcodes

09/03 2018

dev-analysis-zDeD3L

dev-analysis-zDeD3L https://github.com/rapidwebltd/php-postcodes

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

php postcodes php library php postcodes library php postcodes

09/03 2018

v2.1.2

2.1.2.0 https://github.com/rapidwebltd/php-postcodes

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

php postcodes php library php postcodes library php postcodes

30/01 2018

v2.1.1

2.1.1.0 https://github.com/rapidwebltd/php-postcodes

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

  Sources   Download

LGPL-3.0-only

The Requires

 

php postcodes php library php postcodes library php postcodes

28/08 2017

v2.1.0

2.1.0.0 https://github.com/rapidwebltd/php-postcodes

PHP Postcodes

  Sources   Download

LGPL3

The Requires

 

php postcodes php library php postcodes library php postcodes

22/06 2017

v2.0.0

2.0.0.0 https://github.com/rapidwebltd/php-postcodes

PHP Postcodes

  Sources   Download

LGPL3

The Requires

 

php postcodes php library php postcodes library php postcodes

23/05 2017

v1.2.1

1.2.1.0 https://github.com/rapidwebltd/php-postcodes

PHP Postcodes

  Sources   Download

LGPL3

The Requires

 

php postcodes php library php postcodes library php postcodes

11/05 2017

v1.2.0

1.2.0.0 https://github.com/rapidwebltd/php-postcodes

PHP Postcodes

  Sources   Download

LGPL3

The Requires

 

php postcodes php library php postcodes library php postcodes

17/01 2017

v1.1.2

1.1.2.0 https://github.com/rapidwebltd/php-postcodes

PHP Postcodes

  Sources   Download

LGPL3

The Requires

 

php postcodes php library php postcodes library php postcodes

17/01 2017

v1.1.1

1.1.1.0 https://github.com/rapidwebltd/php-postcodes

PHP Postcodes

  Sources   Download

LGPL3

The Requires

 

php postcodes php library php postcodes library php postcodes

16/01 2017

v1.1.0

1.1.0.0 https://github.com/rapidwebltd/php-postcodes

PHP Postcodes

  Sources   Download

LGPL3

The Requires

 

php postcodes php library php postcodes library php postcodes

16/01 2017

v1.0.0

1.0.0.0 https://github.com/rapidwebltd/php-postcodes

PHP Postcodes

  Sources   Download

LGPL3

The Requires

 

php postcodes php library php postcodes library php postcodes