PHPackages                             rubberneck/php-postal-code - 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. rubberneck/php-postal-code

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

rubberneck/php-postal-code
==========================

Calculate the distance between U.S. zip codes and find all zip codes within a given distance of a known zip code.

2.0.1.x-dev(13y ago)5793GPL-3.0PHPPHP &gt;=5.3.0

Since Sep 23Pushed 13y ago1 watchersCompare

[ Source](https://github.com/rubberneck/php-postal-code)[ Packagist](https://packagist.org/packages/rubberneck/php-postal-code)[ Docs](https://github.com/jaywilliams/PHP-ZipCode-Class)[ RSS](/packages/rubberneck-php-postal-code/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHP Postal (Zip) Code Range and Distance Calculation
====================================================

[](#php-postal-zip-code-range-and-distance-calculation)

**Calculate the distance between U.S. zip codes and find all zip codes within a given distance of a known zip code.**

This project was started as a port to PHP 5 of a zip code class I wrote in 2005 for PHP 4. It also provides improvements based on suggestions from users of the original code.

This fork has been modified to be compatible with PHP 5.3+ as well as the [GeoNames.org](http://www.geonames.org/export/)postal code database.

Postal Code Database
--------------------

[](#postal-code-database)

The `PostalCode` class is based on a MySQL table or view with the following fields:

```
country_code    char(2)
postal_code     varchar(20)
place_name      varchar(180)
admin_name1     varchar(100)
admin_code1     varchar(20)
admin_name2     varchar(100)
admin_code2     varchar(20)
admin_name3     varchar(100)
admin_code3     varchar(20)
latitude        float
longitude       float
accuracy        tinyint(1)

```

While the name of this table can be specified by the `mysql_table` class property, the default table name is `postal_codes`.

**Data Source**

The class has been modified to work with the [GeoNames.org postal code database](http://download.geonames.org/export/zip/), which is licensed under a Creative Commons Attribution 3.0 License. This database can be downloaded and imported into a MySQL database using the included schema.

### Composer

[](#composer)

[Composer](http://getcomposer.org/) is an easy way to manage dependencies in your PHP projects. The PHP PostalCode Class can be found in the default [Packagist](http://packagist.org/) repository.

After installing Composer into your project, the PHP PostalCode Class can be installed by adding the following lines to your `composer.json` file and running the Composer command line tool:

```
{
  "require": {
    "rubberneck/php-postal-code": "2.*"
  }
}
```

License
-------

[](#license)

[GNU General Public License v3](http://opensource.org/licenses/gpl-3.0.html)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

Unknown

Total

1

Last Release

4985d ago

### Community

Maintainers

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

---

Top Contributors

[![rubberneck](https://avatars.githubusercontent.com/u/335251?v=4)](https://github.com/rubberneck "rubberneck (4 commits)")[![jaywilliams](https://avatars.githubusercontent.com/u/3330?v=4)](https://github.com/jaywilliams "jaywilliams (1 commits)")

---

Tags

zipcodepostalcode

### Embed Badge

![Health badge](/badges/rubberneck-php-postal-code/health.svg)

```
[![Health](https://phpackages.com/badges/rubberneck-php-postal-code/health.svg)](https://phpackages.com/packages/rubberneck-php-postal-code)
```

###  Alternatives

[barbieswimcrew/zip-code-validator

Constraint class for international zipcode validation

772.3M](/packages/barbieswimcrew-zip-code-validator)[flyingluscas/viacep-php

ViaCEP PHP SDK

3640.2k](/packages/flyingluscas-viacep-php)[magedev/brazilzipcode

Magento 2 module to use brazil zipcode search services.

1119.1k1](/packages/magedev-brazilzipcode)

PHPackages © 2026

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