Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/api-postcode/api-postcode-laravel
Laravel package for Api Postcode
https://github.com/api-postcode/api-postcode-laravel
address api-postcode laravel package php postcode
Last synced: about 6 hours ago
JSON representation
Laravel package for Api Postcode
- Host: GitHub
- URL: https://github.com/api-postcode/api-postcode-laravel
- Owner: api-postcode
- License: mit
- Created: 2017-06-05T16:03:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T12:35:01.000Z (almost 2 years ago)
- Last Synced: 2024-09-17T14:09:44.173Z (2 months ago)
- Topics: address, api-postcode, laravel, package, php, postcode
- Language: PHP
- Homepage: https://api-postcode.nl
- Size: 11.7 KB
- Stars: 3
- Watchers: 1
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Laravel Api Postcode Package
============================A laravel package for fetching Address details
For more information see: [https://api-postcode](https://api-postcode.nl/)
## Requirements ##
Laravel 5.1 or later
Installation
------------
Installation is a quick 3 step process:1. Download api-postcode-laravel using composer
2. Enable the package in app.php
3. Configure your Api Postcode credentials### Step 1: Download api-postcode-laravel using composer
Add api-postcode/api-postcode-laravel by running the command:
```
composer require api-postcode/api-postcode-laravel
```### Step 2: Enable the package in app.php
Register the Service in: **config/app.php**
``` php
ApiPostcode\ApiPostcodeServiceProvider::class,
````Optional - Register the Facade in: **config/app.php**
``` php
'aliases' => [
//...
'Postcode' => ApiPostcode\Facade\Postcode::class,
];
````### Step 3: Configure Api Postcode credentials
```
php artisan vendor:publish --provider="ApiPostcode\ApiPostcodeServiceProvider"
```Add this in you **.env** file
```
API_POSTCODE_TOKEN=secret-token-from-api-postcode
```Usage
-----``` php
$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:
``` php
$address = Postcode::fetchAddress('1012JS', '1')
````Or straight in routes:
``` php
$router->get('postcode/{zipCode}/{number}', function ($zipCode, $number) {
return Postcode::fetchAddress($zipCode, $number);
});
````