Skip to content

UK postcode validation and reverse geocoding via postcodes.io and php

License

Notifications You must be signed in to change notification settings

codescheme/uk-postcodes

Repository files navigation

UK Postcodes

Latest Version on Packagist Software License Build Status Total Downloads

A php API client for the methods at postcodes.io - useful for UK postcode validation and reverse geocoding: that is, determining postcode from lat, long coordinates. No fiddling around with api keys or authentication necessary...

With thanks to https://postcodes.io

Install

Via Composer

$ composer require codescheme/uk-postcodes

Basic Usage

Return data for a given postcode

use Codescheme\Ukpostcodes\Postcode;

$client = new Postcode();

$results = $client->postcodeLookup('SE21 8JL');

if ($results->status === 200) {
    print_r($results);
}

Methods

->validate('SE31 9AX'); //returns boolean
->postcodeLookup('SE21 8JL');
->nearest('SE21 8JL');
->reverseGeocode(-0.397913, 51.44015); // lng,lat
->autocomplete('RG1 3');
->outcodeLookup('SE21');

$postcodes = ['OX49 5NU', 'M32 0JG', 'NE30 1DP'];
->postcodeLookupBulk($postcodes);
	
$coordinates = [
    ['longitude' =>  0.629834723775309, 'latitude' => 51.7923246977375],
    ['longitude' => -2.49690382054704, 	'latitude' => 53.5351312861402]
    ];
->reverseGeocodeBulk($coordinates);

Testing

$ composer test

License

The MIT License (MIT). Please see License File for more information.

About

UK postcode validation and reverse geocoding via postcodes.io and php

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages