nickurt / laravel-postcodeapi
Universal PostcodeApi for Laravel 10.x & 11.x
Installs: 175 840
Dependents: 1
Suggesters: 0
Security: 0
Stars: 89
Watchers: 4
Forks: 18
Open Issues: 0
Requires
- php: ^8.2
- ext-json: *
- guzzlehttp/guzzle: ^7.8.1
- laravel/framework: ^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.5.12
README
Installation
Install this package with composer:
composer require nickurt/laravel-postcodeapi
Copy the config files for the api
php artisan vendor:publish --provider="nickurt\PostcodeApi\ServiceProvider" --tag="config"
Examples
Default - de_DE
$postCode10 = PostcodeApi::create('ZippopotamusDE')->find('07751');
Default - en_AU
$postCode11 = PostcodeApi::create('PostcodeApiComAu')->find('3066');
Default - en_GB
$postCode12 = PostcodeApi::create('GetAddressIO')->find('SW1A1AA'); $postCode13 = PostcodeApi::create('IdealPostcodes')->find('SW1A1AA'); $postCode14 = PostcodeApi::create('PostcodesIO')->find('SW1A1AA');
Default - en_US
$postCode15 = PostcodeApi::create('Bing')->find('92270'); $postCode16 = PostcodeApi::create('Geocodio')->find('92270'); $postCode17 = PostcodeApi::create('Google')->find('92270'); $postCode18 = PostcodeApi::create('Here')->find('92270'); $postCode19 = PostcodeApi::create('LocationIQ')->find('92270'); $postCode20 = PostcodeApi::create('Mapbox')->find('92270'); $postCode21 = PostcodeApi::create('OpenCage')->find('92270'); $postCode22 = PostcodeApi::create('TomTom')->find('92270');
Default - fr_FR
$postCode23 = PostcodeApi::create('AdresseDataGouv')->find('75007'); $postCode24 = PostcodeApi::create('AdresseDataGouv')->findByPostcodeAndHouseNumber('75007', '5 Avenue Anatole France');
Default - nl_BE
$postCode25 = PostcodeApi::create('Pro6PP_BE')->find('1000');
Default - nl_NL
$postCode26 = PostcodeApi::create('ApiPostcode')->findByPostcodeAndHouseNumber('1118CP', '202'); $postCode27 = PostcodeApi::create('NationaalGeoRegister')->find('1118CP'); $postCode28 = PostcodeApi::create('NationaalGeoRegister')->findByPostcodeAndHouseNumber('1118CP', '202'); $postCode29 = PostcodeApi::create('PostcoDe')->findByPostcodeAndHouseNumber('1118CP', '202'); $postCode30 = PostcodeApi::create('PostcodeApiNu')->find('1118CP'); $postCode31 = PostcodeApi::create('PostcodeApiNu')->findByPostcodeAndHouseNumber('1118CP', '202'); $postCode32 = PostcodeApi::create('PostcodeApiNuV3')->find('1118CP'); $postCode33 = PostcodeApi::create('PostcodeApiNuV3')->findByPostcodeAndHouseNumber('1118CP', '202'); $postCode34 = PostcodeApi::create('Pro6PP_NL')->find('1118CP');
Route
Route::get('/{postCode}', function($postCode) { $postCode35 = PostcodeApi::create('PostcodeApiNu')->find($postCode); return Response::json($postCode35->toArray(), 200, [], JSON_PRETTY_PRINT); });
Providers
AdresseDataGouv, ApiPostcode, Bing, Geocodio, GetAddresIO, Google, Here, IdealPostcodes, LocationIQ, Mapbox, NationaalGeoRegister, OpenCage, postco.de, PostcodeApiComAu, PostcodeApiNu, PostcodeNL, PostcodesIO, Pro6PP_BE, Pro6PP_NL, TomTom
Tests
composer test