Giter Site home page Giter Site logo

codescheme / postcodes Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 8.0 158 KB

UK postcode validation. A Laravel 5+ facade/service provider for the GET methods of the API at postcodes.io

License: MIT License

PHP 100.00%
postcode laravel laravel-5-package php postcodes

postcodes's Introduction

Postcodes

A Laravel 5+ facade/service provider for the API 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, authentication, necessary...

With thanks to https://postcodes.io

Installation

composer require codescheme/postcodes

For Laravel 5.5 Postcodes will be automatically discovered.

Edit /config/app.php and add the service provider to your providers array.

'providers' => [
	Codescheme\Postcodes\PostcodeServiceProvider::class,
]

Also here, add the alias:

'aliases' => [
	'Postcode' => Codescheme\Postcodes\Facades\Postcode::class,
]

Basic Example Laravel Usage

Return data for a given postcode

Route::get('/postcode', function(){
    $data = Postcode::postcodeLookup('SE21 8JL');
    print_r($data);
    return null;      
});	

Methods

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

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

Testing

$ composer test

postcodes's People

Contributors

codescheme avatar jmsfwk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.