hpolthof / laravel-postcode-tech
Package to use postcode.tech with Laravel.
Requires
- php: ^7.3|^8.0
- hpolthof/postcode-tech: ^1.0
- laravel/framework: ^6.0|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^4.0
This package is auto-updated.
Last update: 2024-11-29 06:03:49 UTC
README
This is a Laravel implementation for the API of Postcode.Tech. You need an API key for this API to work. You can register for free and create an API Key.
The packages uses the PHP implementation of Postcode.tech.
Installation
To install use composer
composer require hpolthof/laravel-postcode-tech
Usage
Register at Postcode.Tech and create an API token.
Add the following to your .env
file:
POSTCODE_TOKEN="{YOUR TOKEN HERE}"
During installation a service provider and facade will be automatically discovered.
You can now lookup a postcode using:
$address = \Postcode::find('1071BM', 29); if ($address) { $street = $address->street(); $city = $address->city(); }
The method find()
will return null
if the postcode is not found and will return an
exception if there was an error during the API request. These exceptions can be found at: https://github.com/hpolthof/postcode-tech/tree/master/src/Exceptions.
Disclaimer
This package can be used free of charge. Obviously this software comes as is, and there are no warranties or whatsoever.
If you like the package it is always appreciated if you drop a message of gratitude! ;-)
The package was build by: Paul Olthof