Package Data | |
---|---|
Maintainer Username: | api-postcode |
Maintainer Contact: | info@api-postcode.nl (Api Postcode) |
Package Create Date: | 2017-06-05 |
Package Last Update: | 2023-01-03 |
Home Page: | https://api-postcode.nl |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-16 15:02:45 |
Package Statistics | |
---|---|
Total Downloads: | 4,697 |
Monthly Downloads: | 12 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 1 |
Total Forks: | 8 |
Total Open Issues: | 1 |
A laravel package for fetching Address details
For more information see: https://api-postcode
Laravel 5.1 or later
Installation is a quick 3 step process:
Add api-postcode/api-postcode-laravel by running the command:
composer require api-postcode/api-postcode-laravel
Register the Service in: config/app.php
ApiPostcode\ApiPostcodeServiceProvider::class,
Optional - Register the Facade in: config/app.php
'aliases' => [
//...
'Postcode' => ApiPostcode\Facade\Postcode::class,
];
php artisan vendor:publish --provider="ApiPostcode\ApiPostcodeServiceProvider"
Add this in you .env file
API_POSTCODE_TOKEN=secret-token-from-api-postcode
$address = app('api.postcode')->fetchAddress('1012JS', 1);
$address->getStreet(); // Dam
$address->getCity(); // Amsterdam
$address->getHouseNumber(); // 1
$address->getZipCode(); // 1012JS
$address->getLongitude(); // 4.4584
$address->getLatitude(); // 52.2296
Or use the Facade:
$address = Postcode::fetchAddress('1012JS', '1')
Or straight in routes:
$router->get('postcode/{zipCode}/{number}', function ($zipCode, $number) {
return Postcode::fetchAddress($zipCode, $number);
});