2017 © Pedro Peláez
 

library postcodes-io-bundle

A Symfony3 bundle for interaction with the postcodes.io service.

image

proficloud/postcodes-io-bundle

A Symfony3 bundle for interaction with the postcodes.io service.

  • Saturday, March 11, 2017
  • by gigipl
  • Repository
  • 0 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

PostcodesIoBundle

Build Status, (*1)

A bundle for querying the postcodes.io web service., (*2)

https://github.com/ProfiCloud/postcodes-io-bundle, (*3)

License, (*4)

Installation

Installation is handled via Composer., (*5)

  1. Run the following command:, (*6)

    $ composer require proficloud/postcodes-io-bundle ~1.0
    

    This should add the following to your project's composer.json file:, (*7)

    "require": {
        "boxuk/postcodes-io-bundle": "~1.0"
    }
    
  2. Add the bundle to your app/AppKernel.php file:, (*8)

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new BoxUk\PostcodesIoBundle\BoxUkPostcodesIoBundle()
        );
    }
    

Services

This bundle adds two services to your container:, (*9)

  • box_uk_postcodes_io.client A GuzzleHttp\Client configured to query the postcodes.io service.
  • box_uk_postcodes_io.client_factory A factory used to create instances of the client.

Usage

Inject the box_uk_postcodes_io.client service into your controller/class as you would any other service. Once you have the instance of the client, you can call the methods documented below on it, passing any parameters as an associative array., (*10)

The response will be a GuzzleHttp\Command\Model object, which you can access as an array, e.g. echo $response['result']['latitude']. Alternatively, you can just call $response->toArray() to get an array representation of the response. For further documentation on the structure of the response, please see the postcodes.io documentation., (*11)

Methods

lookup()

API documentation, (*12)

Lookup data about a particular postcode., (*13)

Parameters: * postcode (Required): The postcode., (*14)

Example:, (*15)

$response = $client->lookup(array('postcode' => 'CF10 1DD'));

bulkLookup()

API documentation, (*16)

Lookup data about a set of postcodes., (*17)

Parameters: * postcodes (Required): An array of postcodes (max 100)., (*18)

Example:, (*19)

$response = $client->bulkLookup(array('postcodes' => array('CF10 1DD', 'W1B 4BD')));

reverseGeocode()

API documentation, (*20)

Get data for postcodes nearest a given latitude/longitude coordinate., (*21)

Parameters: * latitude (Required): The latitude. * longitude (Required): The longitude. * limit (Optional): The maximum number of postcodes to return (default 10, max 100). * radius (Optional): The radius in metres in which to find postcodes (default 100, max 1000)., (*22)

Example:, (*23)

$response = $client->reverseGeocode(array('latitude' => 51.481667, 'longitude' => -3.182155));

bulkReverseGeocode()

API documentation, (*24)

Bulk translation of latitude/longitude coordinates into postcode data., (*25)

Parameters: * geolocations (Required): The geolocations to look up (maximum 100). This parameter should be an array, each element with the following keys:, (*26)

* `latitude` _(Required)_: The latitude.
* `longitude` _(Required)_: The longitude.
* `limit` _(Optional)_: The maximum number of postcodes to return (default 10, max 100).
* `radius` _(Optional)_: The radius in metres in which to find postcodes (default 100, max 1000).

Example:, (*27)

$response = $client->bulkReverseGeocode(
    array(
        'geolocations' => array(
            array('latitude' => 51.481667, 'longitude' => -3.182155),
            array('latitude' => 51.88328, 'longitude' => -3.43684, 'limit' => 5, 'radius' => 500)
        )
    )
);

matching()

API documentation, (*28)

Find postcodes matching a given query., (*29)

Parameters: * query (Optional): The postcode query, e.g. 'CF10'. * limit (Optional): The maximum number of postcodes to return (default 10, max 100)., (*30)

Example:, (*31)

$response = $client->matching(array('query' => 'CF10', 'limit' => 20));

validate()

API documentation, (*32)

Validate a postcode., (*33)

Parameters: * postcode (Required): The postcode to validate., (*34)

Example:, (*35)

$response = $client->validate(array('postcode' => 'CF10 1DD'));

autocomplete()

API documentation, (*36)

Get a list of postcodes to autocomplete a partial postcode., (*37)

Parameters: * postcode (Required): The postcode to autocomplete. * limit (Optional): The maximum number of postcodes to return (default 10, max 100)., (*38)

Example:, (*39)

$response = $client->autocomplete(array('postcode' => 'CF10', 'limit' => 20));

random()

API documentation, (*40)

Get data for a random postcode., (*41)

Parameters: None., (*42)

Example:, (*43)

$response = $client->random();

outwardCodeLookup()

API documentation, (*44)

Get data for the specified "outward code" (first half of postcode)., (*45)

Parameters: * outcode (Required): The outward code (first half of postcode) to get location data for., (*46)

Example:, (*47)

$response = $client->outwardCodeLookup(array('outcode' => 'CF10'));

The Versions

11/03 2017

dev-master

9999999-dev

A Symfony3 bundle for interaction with the postcodes.io service.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Chris Collins
by Lukasz Grzelak

guzzle postcode postcodes.io

11/03 2017

1.0.1

1.0.1.0

A Symfony3 bundle for interaction with the postcodes.io service.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Chris Collins
by Lukasz Grzelak

guzzle postcode postcodes.io

18/08 2014

1.0.0

1.0.0.0

A Symfony2 bundle for interaction with the postcodes.io service.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Chris Collins

guzzle postcode postcodes.io