wubs / postcode-api
Communicates with the postcodeapi.nu api
Installs: 30
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/wubs/postcode-api
Requires
- php: >=5.5
- guzzlehttp/guzzle: 5.2.0
- illuminate/support: 5.0.x
Requires (Dev)
- phpunit/phpunit: ~4.0
- vlucas/phpdotenv: 2.x-dev
README
This is a simple laravel package to use the dutch postcode api.
Installation
To install this library into your project simply do the following in your project root:
composer require wubs/zip:1.1.*
Laravel specific
If you use Laravel, add 'Wubs\Zip\ZipServiceProvider',
to app/config.php
in the providers array and add 'Zip' => 'Wubs\Zip\Facades\Zip',
to the aliases array, also in app/config.php
.
Usage
You can use the facade like this:
<?php Zip::address("1234AA", 11);
Or get it from the IoC container like so:
<?php $api = $app->make('\Wubs\Zip\ZipApi')
Or inject it into a constructor
<?php namespace App\Http\Controllers; use Wubs\Zip\ZipApi; class ZipController extends Controller { private $api; public function __construct(ZipApi $api) { $this->api = $api; } }
Publish the configuration by running:
php artisan vendor:publish
Afterwards the configuration will be located in config/zip.php
I highly recommend using the .env file.
Non laravel usage
The package is also usable without Laravel. See the code below.
<?php require 'vendor/autoload.php' use Wubs\Zip\ZipApi; $zipApi = new ZipApi("API_KEY"); $address = $postcodeApi->address("1234AA", 11);