PHPackages                             tjbp/countries - 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. tjbp/countries

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

tjbp/countries
==============

Fast and lightweight utilities for ISO 3166 country data.

1215PHP

Since Nov 8Pushed 10y ago1 watchersCompare

[ Source](https://github.com/tjbp/php-countries)[ Packagist](https://packagist.org/packages/tjbp/countries)[ RSS](/packages/tjbp-countries/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

tjbp/countries
==============

[](#tjbpcountries)

A PHP lib providing fast and lightweight utilities for ISO 3166 country data.

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

[](#installation)

Run the following within your project directory to install as a dependency:

```
composer require tjbp/countries
```

Usage
-----

[](#usage)

### Quick start

[](#quick-start)

```
use Tjbp\Currencies\Iso3166;

Iso3166::get('GB')->name; // "United Kingdom of Great Britain and Northern Ireland (the)"
```

### More detailed

[](#more-detailed)

```
use Tjbp\Countries\Iso3166;

// Country object is returned with four properties
Iso3166::get('GB')->name; //
Iso3166::get('GB')->alpha2; // GB
Iso3166::get('GB')->alpha3; // GBR
Iso3166::get('GB')->numeric3; // 826

// Alternatively use an object
$countries = new Iso3166;

$countries->get('GB')->alpha2; // GB

// Or get by specific identifiers if you prefer
Iso3166::getByAlpha2('GB')->alpha2; // GB
Iso3166::getByAlpha3('GBR')->alpha2; // GB
Iso3166::getByNumeric3(826)->alpha2; // GB

// Use the Iso3166::get() method to return a Country object
$country = Iso3166::get('GB');

// Country has four properties
$country->name; // "United Kingdom of Great Britain and Northern Ireland (the)"
$country->alpha2; // "GB"
$country->alpha3; // "GBR"
$country->numeric3; // 826

// Alternatively instantiate Iso3166
$iso4217 = new Iso3166;
$country = $iso4217->get('GBP');

// There are also specific identifiers if you prefer
$country = Iso3166::getByAlpha2('GB');
$country = Iso3166::getByAlpha3('GBP');
$country = Iso3166::getByNumeric3(827);
```

Additionally you can use the HasCountries trait to access the Iso3166::get() method from within an object:

```
use Tjbp\Currencies\HasCountries;

class Example
{
    use HasCountries;

    public method example()
    {
        $this->countries('GB')->name; // "United Kingdom of Great Britain and Northern Ireland (the)"
    }
}
```

Building
--------

[](#building)

Run `bin/build` if you wish to regenerate the library using the latest ISO3166 data (though the packaged source should be up-to-date).

Contributing
------------

[](#contributing)

Changes to the Iso3166 class are made to `src/templates/Iso3166.php`, since `src/Iso3166.php` will be overwritten when new versions are built.

Notes
-----

[](#notes)

Take a look at [https://packagist.org/packages/tjbp/currencies](tjbp/currencies)

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2157634?v=4)[Tom Pitcher](/maintainers/tjbp)[@tjbp](https://github.com/tjbp)

---

Top Contributors

[![tjbp](https://avatars.githubusercontent.com/u/2157634?v=4)](https://github.com/tjbp "tjbp (15 commits)")

### Embed Badge

![Health badge](/badges/tjbp-countries/health.svg)

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

PHPackages © 2026

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