PHPackages                             lodge/postcode-lookup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lodge/postcode-lookup

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lodge/postcode-lookup
=====================

A postcode lookup utility using the Google Maps API, ready to use with Laravel 5.

0.8.0(4y ago)3429.9k↓18.2%15[1 PRs](https://github.com/Daursu/postcode-lookup/pulls)MITPHPPHP &gt;=7.4CI failing

Since Aug 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Daursu/postcode-lookup)[ Packagist](https://packagist.org/packages/lodge/postcode-lookup)[ RSS](/packages/lodge-postcode-lookup/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (10)Used By (0)

Postcode Lookup
===============

[](#postcode-lookup)

[![Latest Stable Version](https://camo.githubusercontent.com/6dbd90d4873b762bbcfa75439e80e4dc906a995a05acc0ee683dc5512b4db5c0/68747470733a2f2f706f7365722e707567782e6f72672f6c6f6467652f706f7374636f64652d6c6f6f6b75702f762f737461626c652e737667)](https://packagist.org/packages/lodge/postcode-lookup) [![Total Downloads](https://camo.githubusercontent.com/dba83d3de58710b3b4538a3025767f6cf42073e683751640226b045baa22564e/68747470733a2f2f706f7365722e707567782e6f72672f6c6f6467652f706f7374636f64652d6c6f6f6b75702f646f776e6c6f6164732e737667)](https://packagist.org/packages/lodge/postcode-lookup) [![Latest Unstable Version](https://camo.githubusercontent.com/d7badbac4eb00bf752c9ea4c26527d2936a0e678103a4267a97b072737b92fca/68747470733a2f2f706f7365722e707567782e6f72672f6c6f6467652f706f7374636f64652d6c6f6f6b75702f762f756e737461626c652e737667)](https://packagist.org/packages/lodge/postcode-lookup) [![License](https://camo.githubusercontent.com/5b128de2da929bd22489855d49255a39bbf48ba2d4b6441f7e921052d1fdf84e/68747470733a2f2f706f7365722e707567782e6f72672f6c6f6467652f706f7374636f64652d6c6f6f6b75702f6c6963656e73652e737667)](https://packagist.org/packages/lodge/postcode-lookup)

PHP library that performs a postcode lookup using Google Maps API.

#### Compatible with Laravel 4-8.

[](#compatible-with-laravel-4-8)

Quick start
-----------

[](#quick-start)

First of all you need to require the package inside your `composer.json` file:

```
{
    "require": {
        "lodge/postcode-lookup": "0.7.0"
    }
}

```

Note: for Laravel 4 use version `0.3.0`

### Register with Laravel

[](#register-with-laravel)

Register the service provider. Inside your `app.php` config file add:

```
'providers' => array(
	...
	'Lodge\Postcode\PostcodeServiceProvider',
)

```

A facade is also provided, so in order to register it add the following to your `app.php` config file:

```
'aliases' => array(
	...
	'Postcode' => 'Lodge\Postcode\Facades\Postcode',
);

```

Publish the configuration file.

```
php artisan vendor:publish --provider="Lodge\Postcode\PostcodeServiceProvider"

```

Set your Google API key inside `config/postcode.php` file.

Usage with Laravel
------------------

[](#usage-with-laravel)

From within your controller you can call:

```
	$postcode = Postcode::lookup('SW3 4SZ');

	print_r($postcode);

	// Outputs
	array(
		'postcode'      => 'SW34SZ',
		'street_number' => '',
		'street'        => '',
		'sublocality'   => '',
		'town'          => 'London',
		'county'        => 'Greater London',
		'country'       => 'United Kingdom',
		'latitude'      => 51.489117499999999,
		'longitude'     => -0.1579016
	);

```

#### Get the Latitude and Longitude of an address

[](#get-the-latitude-and-longitude-of-an-address)

```
	$coordinates = Postcode::getCoordinates($address);

	print_r($coordinates);

	// Outputs
	array(
		'latitude'  => 1.521231
		'longitude' => -23.012123
	)

```

Usage outside of Laravel
------------------------

[](#usage-outside-of-laravel)

```
	// First of all you need to instantiate the class
	// And assuming that you have required the composer
	// autoload.php file
	require 'vendor/autoload.php';

    $googleApiKey = 'your-google-api-key';
	$postcode = new Lodge\Postcode\Postcode($googleApiKey);
	$results = $postcode->lookup('SW3 4SZ');

	print_r($results);

	// Outputs
	array(
		'postcode'      => 'SW34SZ',
		'street_number' => '',
		'street'        => '',
		'sublocality'   => '',
		'town'          => 'London',
		'county'        => 'Greater London',
		'country'       => 'United Kingdom',
		'latitude'      => 51.489117499999999,
		'longitude'     => -0.1579016
	)

```

If you need to get just the latitude and longitude for an address you can use:

```
    $googleApiKey = 'your-google-api-key';
	$postcode = new Lodge\Postcode\Postcode($googleApiKey);
	$results = $postcode->getCoordinates('SW3 4SZ');

	print_r($results);

	// Outputs
	array(
		'latitude'  => 51.489117499999999
		'longitude' => -0.1579016
	)

```

Changelog
---------

[](#changelog)

- **Version 0.7**

    - Added support for Laravel 8
- **Version 0.6**

    - Added support for Laravel 7
- **Version 0.4**

    - Added configuration file and the ability to set the Google API key.
    - Updated namespaces to PSR-4
    - Added test stubs.
    - Dropped support for Laravel 4.
- **Version 0.3**

    - Removed deprecated `bind` call and instantiate as a singleton instead.
- **Version 0.2**

    - Laravel 5 compatible
    - Fixed facade namespace, that would not adhere to PSR-0
    - Updated documentation
- **Version 0.1**

    - Initial Release

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2013-2015 Dan Ursu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~444 days

Recently: every ~365 days

Total

8

Last Release

1558d ago

PHP version history (3 changes)0.1.1PHP &gt;=5.3.0

0.4.1PHP &gt;=5.4.0

0.8.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/ddc404d18abd532ba55e259f5b4852495a18cd779740de3ba4c3c51fe2096095?d=identicon)[daursu](/maintainers/daursu)

---

Top Contributors

[![Daursu](https://avatars.githubusercontent.com/u/3728832?v=4)](https://github.com/Daursu "Daursu (12 commits)")[![sjelfull](https://avatars.githubusercontent.com/u/10508?v=4)](https://github.com/sjelfull "sjelfull (3 commits)")[![alphamarket](https://avatars.githubusercontent.com/u/2348936?v=4)](https://github.com/alphamarket "alphamarket (1 commits)")[![StevenBullen](https://avatars.githubusercontent.com/u/239862?v=4)](https://github.com/StevenBullen "StevenBullen (1 commits)")[![warksit](https://avatars.githubusercontent.com/u/5296633?v=4)](https://github.com/warksit "warksit (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![applyACS](https://avatars.githubusercontent.com/u/13115651?v=4)](https://github.com/applyACS "applyACS (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lodge-postcode-lookup/health.svg)

```
[![Health](https://phpackages.com/badges/lodge-postcode-lookup/health.svg)](https://phpackages.com/packages/lodge-postcode-lookup)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
