PHPackages                             php-components/isocodes - 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. php-components/isocodes

ActiveLibrary

php-components/isocodes
=======================

PHP implementation of ISO codes package

v1.0.0-beta.2(9y ago)75.4k7[1 issues](https://github.com/php-components/isocodes/issues)[1 PRs](https://github.com/php-components/isocodes/pulls)GPLv3PHPPHP ^5.4 || ^7.0

Since Oct 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/php-components/isocodes)[ Packagist](https://packagist.org/packages/php-components/isocodes)[ RSS](/packages/php-components-isocodes/feed)WikiDiscussions master Synced 2mo ago

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

PHP ISO Codes
=============

[](#php-iso-codes)

[![Build Status](https://camo.githubusercontent.com/bd17d43a51bf28644b023e4f3dba31922f82b6f1460d1a8cb09d8fca130479e2/68747470733a2f2f7472617669732d63692e6f72672f7068702d636f6d706f6e656e74732f69736f636f6465732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-components/isocodes)

PHP ISO codes based on the open source [iso-codes](https://pkg-isocodes.alioth.debian.org/) project.

This project includes:

- ISO-15924
- ISO-3166-1
- ISO-3166-2
- ISO-3166-3
- ISO-4217
- ISO-639-2
- ISO-639-3
- ISO-639-5

...and the appropiate translations which are managed through the [Translation Project](https://www.translationproject.org/html/welcome.html).

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

[](#installation)

The easiest and recommended way to install this library is through [composer](http://getcomposer.org/):

```
composer require php-components/isocodes

```

Adapters
--------

[](#adapters)

Adapters are used in order to load the ISO data. Currently we support the following adapters:

- Json
- Pdo

However there are interfaces in place so you can write your own custom adapter. If you write your own adapter keep in mind it must inject the translator object into the objects.

The `get($code)` will determine which type of code has been supplied as an argument and will search for that type of code. The allowed types are the Alpha-2, Alpha-3, Alpha-4 and Numeric codes (If available in the requested ISO).

Some ISO files, such as ISO-639 have additional codes that match the pattern of Alpha-2, Alpha-3, Alpha-4 or Numeric codes. For those special cases an additional method is added to their adapters.

### JSON Adapter

[](#json-adapter)

This adapter makes use of [iso-codes](https://pkg-isocodes.alioth.debian.org/) JSON files to provide the ISO data. The data is stored as an array inside the adapter interfaces.

#### Usage Example:

[](#usage-example)

```
use ISOCodes\ISO3166_1\Adapter\Json as ISO3166_1Adapter;

$adapter = new ISO3166_1Adapter();
// Get country with Alpha-2 code 'es' (Spain)
$country = $adapter->get('es');

if (null !== $country) {
    // Get the country name in Spanish ('es')
    echo $country->getName('es');
} else {
    echo 'Country not found!';
}

```

This shall return `España`

### PDO Adapter

[](#pdo-adapter)

This adapter makes use of PDO to retrieve the ISO data from a database backend. By default it will use the included SQLite database but you may specify another PDO in the constructor of the adapter. The constuctor is defined as follows:

```
public function __construct(PDO $pdo = null)

```

`$pdo` will be you PDO object or you can leave it as null in order to load the default SQLite database.

#### Usage Example

[](#usage-example-1)

```
use ISOCodes\ISO3166_1\Adapter\Pdo as ISO3166_1Adapter;

$adapter = new ISO3166_1Adapter();
// Get country with Alpha-2 code 'es' (Spain)
$country = $adapter->get('es');

if (null !== $country) {
    // Get the country name in Spanish ('es')
    echo $country->getName('es');
} else {
    echo 'Country not found!';
}

```

This shall return `España`

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

2

Last Release

3489d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88eadf341a8c89449a4172b467aa59dccc90167cfa8ae9badab0434232e2c50d?d=identicon)[JPG-Consulting](/maintainers/JPG-Consulting)

---

Top Contributors

[![oscherler](https://avatars.githubusercontent.com/u/189712?v=4)](https://github.com/oscherler "oscherler (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/php-components-isocodes/health.svg)

```
[![Health](https://phpackages.com/badges/php-components-isocodes/health.svg)](https://phpackages.com/packages/php-components-isocodes)
```

PHPackages © 2026

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