PHPackages                             jflight/nearby-uk-postcode-finder - 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. jflight/nearby-uk-postcode-finder

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

jflight/nearby-uk-postcode-finder
=================================

Find all UK Ppostcodes within the radius of a postcode

0.0.2(11y ago)01811PHP

Since Jul 26Pushed 11y ago1 watchersCompare

[ Source](https://github.com/jamesflight/Nearby-UK-Postcode-Finder)[ Packagist](https://packagist.org/packages/jflight/nearby-uk-postcode-finder)[ RSS](/packages/jflight-nearby-uk-postcode-finder/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

PHP Nearby UK Postcode Finder
=============================

[](#php-nearby-uk-postcode-finder)

The postcode finder takes a UK postcode outcode (the bit before the space) and a radius, and returns all other uk postcodes within that radius.

It is powered by a csv file of postcodes and their longitude and latitude coordinates, and shouldn't be used in production environments where speed is important. The project makes use of the excellent [Geotools](http://geotools-php.org/) library.

Installation
------------

[](#installation)

Add to composer.json:

```
    "require": {
        "jflight/nearby-uk-postcode-finder": "dev-master"
    }
```

Run:

```
composer update
```

Usage
-----

[](#usage)

Create a postcode:

```
$postcode = new Jflight\PostcodeFinder\UkPostcode('CF11');
```

Get postcodes within a radius of 10 km:

```
$nearbyPostcodes = $postcode->findNearestPostcodes(10)); // Array of postcodes
```

Extension
---------

[](#extension)

In theory, the postcode class could be extended and used for postcodes (or equivalent) for any county, as long as csv lookup of postcodes with their longitude and latitue is available.

This would be done as follows:

```
