Skip to content

bartjackbakker/api-postcode-laravel

This branch is 3 commits ahead of api-postcode/api-postcode-laravel:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
bartjackbakker
Feb 16, 2025
3557aab · Feb 16, 2025

History

31 Commits
Jun 12, 2017
Jun 5, 2017
Jun 5, 2017
Jun 5, 2017
Jun 26, 2017
Feb 16, 2025

Repository files navigation

Laravel Api Postcode Package

A laravel package for fetching Address details

For more information see: https://api-postcode

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

ApiPostcode\ApiPostcodeServiceProvider::class,

Optional - Register the Facade in: config/app.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

$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:

$address = Postcode::fetchAddress('1012JS', '1')

Or straight in routes:

$router->get('postcode/{zipCode}/{number}', function ($zipCode, $number) {
    return Postcode::fetchAddress($zipCode, $number);
});

About

Laravel package for Api Postcode

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%