PHPackages                             datingvip/geo - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. datingvip/geo

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

datingvip/geo
=============

Geographical data helpers

v1.0.10(8y ago)224.3k↓23.5%LGPL-3.0-or-laterPHPPHP &gt;=5.4.0

Since Apr 11Pushed 8y ago18 watchersCompare

[ Source](https://github.com/DatingVIP/geo)[ Packagist](https://packagist.org/packages/datingvip/geo)[ Docs](https://github.com/DatingVIP/geo)[ RSS](/packages/datingvip-geo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (11)Used By (0)

geo
===

[](#geo)

Geographical data helpers

ISO / FIPS code conversions
===========================

[](#iso--fips-code-conversions)

Convert `FIPS 10-4` to `ISO 3166-1` code, or vice versa:

```
require_once 'vendor/autoload.php';

use DatingVIP\geo\Country_Code;

echo (new Country_Code)->fips2iso ('SG');
// outputs: SN

echo (new Country_Code)->iso2fips ('PR');
// outputs: RQ
```

Postal Code Validation
======================

[](#postal-code-validation)

Validate or parse Postal Codes for almost any country (using regular expressions). Country codes are accepted in `ISO 3166-1` format.

```
require_once 'vendor/autoload.php';

use DatingVIP\geo\Postal_Code;
use DatingVIP\geo\Validation_Exception;

$postal_code = new Postal_Code ();

// check if country is covered
var_dump ($postal_code->coveringCountry ('SG'));
// bool(true)

// get an array of human readable postal code formats for given country
var_dump ($postal_code->getFormats ('RS'));
// array(1) {
//  [0]=>
//  string(5) "#####"
//}

// check if zip code is valid
var_dump ($postal_code->isValid ('RS', '11000'));
// bool(true)

try {
	$postal_code->isValid ('WW', '....');
} catch (Validation_Exception $e) {
	var_dump ($e->getMessage());
	// string(26) "Invalid country code: "WW""
}

if ($postal_code->contains ('RS', '11000, Beograd'))
{
	var_dump ($postal_code->capture ('RS', '11000, Beograd'));
	// string(5) "11000"
}
```

Map of wildcards to regexes:

- `#` = `0-9`
- `@` = `a-zA-Z`
- `*` = `a-zA-Z0-9`

State Codes
===========

[](#state-codes)

`ISO 3166-2` principal subdivisions (provinces, states, regions) utility class

```
require_once 'vendor/autoload.php';

use DatingVIP\geo\State_Code;

$state_code = new State_Code ();

// get available states/regions in given country
var_dump ($state_code->getCountry ('CY'));
//array(6) {
//  ["04"]=>
//  string(12) "Ammóchostos"
//  ["06"]=>
//  string(9) "Kerýneia"
//  ["03"]=>
//  string(8) "Lárnaka"
//  ["01"]=>
//  string(9) "Lefkosía"
//  ["02"]=>
//  string(8) "Lemesós"
//  ["05"]=>
//  string(6) "Páfos"
//}

// get region/state name based on given code
var_dump ($state_code->getName ('CY', '02'));
//string(8) "Lemesós"

// get region/state code based on given name
var_dump ($state_code->get ('US', 'Alabama'));
//string(2) "AL"

// check if given country / state code combo is valid
var_dump ($state_code->isValid ('AB', 'CD'));
//bool(false)

// check if given country / state code combo is valid
var_dump ($state_code->isValid ('RS', '03'));
//bool(true)
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 96.2% 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 ~163 days

Recently: every ~362 days

Total

10

Last Release

2954d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/725986?v=4)[Boris Momčilović](/maintainers/kornrunner)[@kornrunner](https://github.com/kornrunner)

---

Top Contributors

[![kornrunner](https://avatars.githubusercontent.com/u/725986?v=4)](https://github.com/kornrunner "kornrunner (25 commits)")[![krakjoe](https://avatars.githubusercontent.com/u/2236138?v=4)](https://github.com/krakjoe "krakjoe (1 commits)")

---

Tags

fips-10-4iso-3166-1iso-3166-2validationgeoiso\_3166\_2postal-codeISO 3166-1FIPS 10-4

### Embed Badge

![Health badge](/badges/datingvip-geo/health.svg)

```
[![Health](https://phpackages.com/badges/datingvip-geo/health.svg)](https://phpackages.com/packages/datingvip-geo)
```

###  Alternatives

[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k489.6M672](/packages/composer-semver)[giggsey/libphonenumber-for-php

A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.

5.0k148.7M416](/packages/giggsey-libphonenumber-for-php)[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[opis/json-schema

Json Schema Validator for PHP

64736.9M186](/packages/opis-json-schema)

PHPackages © 2026

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