2017 © Pedro Peláez
 

library laravel-postcode-nl

A Laravel client using the Postcode.nl REST API for Dutch address verification.

image

speelpenning/laravel-postcode-nl

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  • Thursday, December 21, 2017
  • by gbs
  • Repository
  • 2 Watchers
  • 5 Stars
  • 2,660 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 1 Open issues
  • 15 Versions
  • 10 % Grown

The README.md

Postcode.nl client for Laravel 8

Build Status License, (*1)

A client using the Postcode.nl REST API for Dutch address verification., (*2)

Installation

Pull the package in through Composer:, (*3)

composer require speelpenning/laravel-postcode-nl

Next, register an account with Postcode.nl to obtain a key and secret. See https://api.postcode.nl/#register for further information. Once you have a key and secret, store them in your .env file., (*4)

Add the following service provider to your application config:, (*5)

Speelpenning\PostcodeNl\PostcodeNlServiceProvider::class,

Walk through the configuration section to make things work., (*6)

Usage

There are two ways to use the address lookup: by injecting the address lookup service in your code or using the AddressController that is shipped with the package., (*7)

Dependency injection

Example:, (*8)

<?php

use Exception;
use Speelpenning\PostcodeNl\Services\AddressLookup;

class AddressDumper {

    /**
     * @var AddressLookup
     */
    protected $lookup;

    /**
     * Create an address dumper instance.
     *
     * @param AddressLookup $lookup
     */
    public function __construct(AddressLookup $lookup)
    {
        $this->lookup = $lookup;
    }

    /**
     * Dumps the address details on screen.
     *
     * @param string $postcode
     * @param int $houseNumber
     * @param null|string $houseNumberAddition
     */
    public function dump($postcode, $houseNumber, $houseNumberAddition = null)
    {
        try {
            $address = $this->lookup->lookup($postcode, $houseNumber, $houseNumberAddition);
            dd($address);
        }
        catch (Exception $e) {
            exit('Ow, that went wrong...');
        }
    }

}

Using the JSON API

In order to use the API, enabled it in the configuration. When enabled, the following route is available:, (*9)

route('postcode-nl::address', [$postcode, $houseNumber, $houseNumberAddition = null]);

or use the following URL (e.g. for AJAX calls):, (*10)

/postcode-nl/address/{postcode}/{houseNumber}/{houseNumberAddition?}

Configuration

Credentials (required)

The key and secret are used for authentication. Without them, you cannot use the service., (*11)

POSTCODENL_KEY=<your-api-key>
POSTCODENL_SECRET=<your-secret>

Enable routes (optional)

This package comes with a ready to use JSON API, which is disabled by default. You can enable it like so:, (*12)

POSTCODENL_ENABLE_ROUTES=true

Timeout (in seconds, optional)

By default, the client waits 10 seconds for a response. You may set a different timeout., (*13)

POSTCODENL_TIMEOUT=<timeout-in-seconds>

The Versions

21/12 2017

dev-master

9999999-dev

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

06/04 2017

v3.0.3

3.0.3.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

20/03 2017

v3.0.2

3.0.2.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

20/02 2017

v3.0.1

3.0.1.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

20/02 2017

v3.0

3.0.0.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

20/02 2017

v2.0.1

2.0.1.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

11/11 2016

v2.0

2.0.0.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

08/02 2016

1.0.x-dev

1.0.9999999.9999999-dev

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

08/02 2016

v1.0.6

1.0.6.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

24/10 2015

v1.0.5

1.0.5.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

18/08 2015

v1.0.4

1.0.4.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

18/08 2015

v1.0.3

1.0.3.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

14/08 2015

v1.0.2

1.0.2.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

14/08 2015

v1.0.1

1.0.1.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning

14/08 2015

v1.0

1.0.0.0

A Laravel client using the Postcode.nl REST API for Dutch address verification.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gerben Speelpenning