Universal PostcodeApi for Laravel 5.7
Switch branches/tags
Clone or download
Permalink
Failed to load latest commit information.
config
src
tests/Providers
.gitignore
README.md
composer.json
phpunit.xml.dist

README.md

Laravel PostcodeApi

Installation

Install this package with composer:

composer require nickurt/laravel-postcodeapi

Add the provider to config/app.php file

'nickurt\PostcodeApi\ServiceProvider',

and the facade in the file

'PostcodeApi' => 'nickurt\PostcodeApi\Facade',

Copy the config files for the api

php artisan vendor:publish --provider="nickurt\PostcodeApi\ServiceProvider" --tag="config"

Examples

Default - en_AU

$postCode10 = PostcodeApi::create('PostcodeApiComAu')->find('3066');

Default - en_GB

$postCode11 = PostcodeApi::create('GeoPostcodeOrgUk')->find('SW1A1AA');
$postCode12 = PostcodeApi::create('GetAddressIO')->find('SW1A1AA');
$postCode13 = PostcodeApi::create('IdealPostcodes')->find('SW1A1AA');
$postCode14 = PostcodeApi::create('PostcodesIO')->find('SW1A1AA');
$postCode15 = PostcodeApi::create('UkPostcodes')->find('SW1A1AA');

Default - en_US

$postCode16 = PostcodeApi::create('Geocodio')->find('42370+Bob+Hope+Drive,+Rancho+Mirage+CA');

Default - fr_FR

$postCode17 = PostcodeApi::create('AdresseDataGouv')->find('75007');
$postCode18 = PostcodeApi::create('AdresseDataGouv')->findByPostcodeAndHouseNumber('75007', '5 Avenue Anatole France');

Default - nl_BE

$postCode19 = PostcodeApi::create('Pro6PP_BE')->find('1000');

Default - nl_NL

$postCode20 = PostcodeApi::create('PostcodeApiNu')->find('1118CP');
$postCode21 = PostcodeApi::create('PostcodeApiNu')->findByPostcodeAndHouseNumber('1118CP', '202');
$postCode22 = PostcodeApi::create('PostcodeData')->findByPostcodeAndHouseNumber('1118CP', '202');
$postCode23 = PostcodeApi::create('PostcodeNL')->findByPostcodeAndHouseNumber('1118CP', '202');
$postCode24 = PostcodeApi::create('Pro6PP_NL')->find('1118CP');
$postCode25 = PostcodeApi::create('Pstcd')->find('1118CP');
$postCode26 = PostcodeApi::create('Pstcd')->findByPostcodeAndHouseNumber('1118CP', '202');

Route

Route::get('/{postCode}', function($postCode) {
    $postCode27 = PostcodeApi::create('PostcodeApiNu')->find($postCode);
    
    return Response::json($postCode25->toArray(), 200, [], JSON_PRETTY_PRINT);
});

Providers

AdresseDataGouv, Geocodio, GeoPostcodeOrgUk, GetAddresIO, IdealPostcodes, PostcodeApiComAu, PostcodeApiNu, PostcodeData, PostcodeNL, PostcodesIO, Pro6PP_BE, Pro6PP_NL, Pstcd, UkPostcodes

Tests

phpunit