vladshut / postcode-bundle
Symfony Postcode bundle
Package info
github.com/vladshut/postcode-bundle
Type:symfony-bundle
pkg:composer/vladshut/postcode-bundle
3.3
2019-05-11 09:17 UTC
Requires
- php: >=7.2
- ext-json: *
- guzzlehttp/guzzle: ^6.2
- php-http/guzzle6-adapter: ^1.1
- symfony/framework-bundle: >=2.7
- vladshut/postcode-api-client: 1.0
Requires (Dev)
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This bundle can be useed to fetch Address details from zipcode with number. An account at Apiwise is required. For more information please take a look at: https://www.postcodeapi.nu
Installation
Installation is a quick 4 step process:
- Download postcode-bundle using composer
- Enable the Bundle in AppKernel.php
- Configure Apiwise credentials
- Add routes
Step 1: Download postcode-bundle using composer
Add UsoftPostcodeBundle by running the command:
$ composer require shivella/postcode-bundle
Step 2: Enable the Bundle in AppKernel.php
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Usoft\PostcodeBundle\UsoftPostcodeBundle(), ); }
Step 3: Configure Apiwise credentials
# app/config/config.yml # Apiwise Postcode API usoft_postcode: apiwise: key: secret_api_wise_key
Step 4. Add routes
# app/config/routing.yml postcode: resource: "@UsoftPostcodeBundle/Resources/config/routing.yml" prefix: /
Usage Services
$address = $this->get('usoft.postcode.client')->getAddress('1012JS', 1); $address->getStreet(); // Dam $address->getCity(); // Amsterdam $address->getMunicipality(); // Amsterdam $address->getProvince(); // Noord-Holland $address->getNumber(); // 1 $address->getZipcode(); // 1012JS $address->getGeoLocation(); // array('latitude' => 52.3732926, 'longitude' => 4.8937176)
Usage from API
Or try the API response: