nickurt / laravel-postcodeapi by nickurt

Universal PostcodeApi for Laravel 8.x & 9.x
175,907
89
4
Package Data
Maintainer Username: nickurt
Package Create Date: 2015-03-01
Package Last Update: 2024-03-23
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-12-29 03:00:12
Package Statistics
Total Downloads: 175,907
Monthly Downloads: 2,530
Daily Downloads: 4
Total Stars: 89
Total Watchers: 4
Total Forks: 18
Total Open Issues: 0

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