PHPackages                             chroma-x/iso3166-country-information - 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. chroma-x/iso3166-country-information

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

chroma-x/iso3166-country-information
====================================

ISO3166 util class for validating and listing country codes and getting detailed information for identified countries.

3.0.2(5y ago)01.8k↓100%MITPHPPHP &gt;=5.3

Since Feb 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/chroma-x/php-iso3166-country-information)[ Packagist](https://packagist.org/packages/chroma-x/iso3166-country-information)[ Docs](http://chroma-x.de/)[ RSS](/packages/chroma-x-iso3166-country-information/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

PHP ISO3166 Country Information
===============================

[](#php-iso3166-country-information)

[![Build Status](https://camo.githubusercontent.com/8b09561431fb2804c24e99be1925c4e578816702c70f7b68437ce58697d4c1ed/68747470733a2f2f7472617669732d63692e6f72672f6368726f6d612d782f7068702d69736f333136362d636f756e7472792d696e666f726d6174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/chroma-x/php-iso3166-country-information)[![Test Coverage](https://camo.githubusercontent.com/7e7c9d6d3f184bb33b723251f415eeafa623db7fcf336dbbdb82127131b11b51/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6368726f6d612d782f7068702d69736f333136362d636f756e7472792d696e666f726d6174696f6e2f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/chroma-x/php-iso3166-country-information/coverage)[![SensioLabs Insight](https://camo.githubusercontent.com/00fc19f1af20ecb67f339d1a2e89fbf9f83f1358431cf341bce3e9b76e23447f/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f66333163396462352d663838342d346161302d383136312d3435636664643831303731612e737667)](https://insight.sensiolabs.com/projects/f31c9db5-f884-4aa0-8161-45cfdd81071a)[![Code Climate](https://camo.githubusercontent.com/edb444a14e99498121f705427632789af83953f95ec3e25157a5aeaf321f8032/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6368726f6d612d782f7068702d69736f333136362d636f756e7472792d696e666f726d6174696f6e2f6261646765732f6770612e737667)](https://codeclimate.com/github/chroma-x/php-iso3166-country-information)[![Latest Stable Version](https://camo.githubusercontent.com/b72f1f89ef79c974c80c44aee24072dd3dd25771c90ae1e33da6f9d5e737bd85/68747470733a2f2f706f7365722e707567782e6f72672f6368726f6d612d782f69736f333136362d636f756e7472792d696e666f726d6174696f6e2f762f737461626c65)](https://packagist.org/packages/chroma-x/iso3166-country-information)[![Total Downloads](https://camo.githubusercontent.com/90459a3d051c2d8940e4ee9ae0a1a127a2925a62b001a75da6e3a451d8d1a795/68747470733a2f2f706f7365722e707567782e6f72672f6368726f6d612d782f69736f333136362d636f756e7472792d696e666f726d6174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/chroma-x/iso3166-country-information)[![License](https://camo.githubusercontent.com/947f21e2eaf471ca93ef6004ade68f40fe29cb0805c909e1ab3182711a8f7261/68747470733a2f2f706f7365722e707567782e6f72672f6368726f6d612d782f69736f333136362d636f756e7472792d696e666f726d6174696f6e2f6c6963656e7365)](https://packagist.org/packages/chroma-x/iso3166-country-information)

ISO3166 util class for validating and listing country codes and getting detailed information for identified countries.

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

[](#installation)

```
{
   	"require": {
        "chroma-x/iso3166-country-information": "~3.0"
    }
}

```

Usage
-----

[](#usage)

### Autoloading and namesapce

[](#autoloading-and-namesapce)

```
require_once('path/to/vendor/autoload.php');

use ChromaX\Iso3166Country\Iso3166CountryInformation;
use ChromaX\Iso3166Country\Iso3166Country;

```

---

### Getting information about all countries existing in ISO3166

[](#getting-information-about-all-countries-existing-in-iso3166)

#### Get all countries as array of hashmaps containing the country information

[](#get-all-countries-as-array-of-hashmaps-containing-the-country-information)

```
$arrayOfIso3166Countries = Iso3166CountryInformation::getCountryData();

```

##### Result

[](#result)

```
…
[RU] => Array
	(
		[iso3166_alpha2] => RU
		[iso3166_alpha3] => RUS
		[iso3166_numeric] => 643
		[iso3166_2] => RU
		[un] => RU
		[tld] => ru
		[name] => Russische Föderation
	)
[SB] => Array
	(
		[iso3166_alpha2] => SB
		[iso3166_alpha3] => SLB
		[iso3166_numeric] => 090
		[iso3166_2] => SB
		[un] => SB
		[tld] => sb
		[name] => Salomonen
)
…

```

---

#### Get all countries as array of Iso3166Country objects

[](#get-all-countries-as-array-of-iso3166country-objects)

```
$arrayOfIso3166CountryObjects = Iso3166CountryInformation::getCountries();

```

##### Result

[](#result-1)

```
…
[CX] => Iso3166Country\Iso3166Country Object
	(
		[iso3166Alpha2CountryCode:Iso3166Country\Iso3166Country:private] => CX
		[iso3166Alpha3CountryCode:Iso3166Country\Iso3166Country:private] => CXR
		[iso3166NumericCountryCode:Iso3166Country\Iso3166Country:private] => 162
		[iso3166_2CountryCode:Iso3166Country\Iso3166Country:private] => CX
		[toplevelDomain:Iso3166Country\Iso3166Country:private] => cx
		[unitedNationsCountryCode:Iso3166Country\Iso3166Country:private] => CX
		[name:Iso3166Country\Iso3166Country:private] => Weihnachtsinsel
	)
[EH] => Iso3166Country\Iso3166Country Object
	(
		[iso3166Alpha2CountryCode:Iso3166Country\Iso3166Country:private] => EH
		[iso3166Alpha3CountryCode:Iso3166Country\Iso3166Country:private] => ESH
		[iso3166NumericCountryCode:Iso3166Country\Iso3166Country:private] => 732
		[iso3166_2CountryCode:Iso3166Country\Iso3166Country:private] => EH
		[toplevelDomain:Iso3166Country\Iso3166Country:private] => eh
		[unitedNationsCountryCode:Iso3166Country\Iso3166Country:private] => EH
		[name:Iso3166Country\Iso3166Country:private] => Westsahara
	)
…

```

---

#### Get all countries as a string containing HTML option tags.

[](#get-all-countries-as-a-string-containing-html-option-tags)

```
// Argument 1 ('DE') ist the selected option,
// argument 2 (ISO3166_ALPHA2) property is the value,
// argument 2 (NAME) property is the label.
$optionsOfIso3166Countries = Iso3166CountryInformation::getSelectOptions(
	'DE',
	Iso3166CountryInformation::ISO3166_ALPHA2,
	Iso3166CountryInformation::NAME
);

```

#### Result

[](#result-2)

```
Afghanistan
Ägypten
Åland
Albanien
Algerien
Amerikanisch-Samoa
Amerikanische Jungferninseln
Andorra
…
Deutchland
…

```

---

### Getting information about a single country identified by one of the ISO3166 properties

[](#getting-information-about-a-single-country-identified-by-one-of-the-iso3166-properties)

#### Get info for the ISO3166Alpha2 country code 'de' (Germany)

[](#get-info-for-the-iso3166alpha2-country-code-de-germany)

```
$iso3166Country = Iso3166CountryInformation::getByIso3166Alpha2('de');

```

#### Get info for the ISO3166Alpha3 country code 'deu' (Germany)

[](#get-info-for-the-iso3166alpha3-country-code-deu-germany)

```
$iso3166Country = Iso3166CountryInformation::getByIso3166Alpha3('deu');

```

#### Get info for the ISO3166Numeric country code '276' (Germany)

[](#get-info-for-the-iso3166numeric-country-code-276-germany)

```
$iso3166Country = Iso3166CountryInformation::getByIso3166Numeric(276);

```

#### Get info for the ISO3166-2 country code 'de' (Germany)

[](#get-info-for-the-iso3166-2-country-code-de-germany)

```
$iso3166Country = Iso3166CountryInformation::getByIso3166v2('de');

```

#### Get info for the ISO3166 top level domain 'de' (Germany)

[](#get-info-for-the-iso3166-top-level-domain-de-germany)

```
$iso3166Country = Iso3166CountryInformation::getByToplevelDomain('de');

```

#### Get info for the ISO3166 united nations identifier 'de' (Germany)

[](#get-info-for-the-iso3166-united-nations-identifier-de-germany)

```
$iso3166Country = Iso3166CountryInformation::getByUnitedNationsId('de');

```

##### Result

[](#result-3)

```
$iso3166Country => Iso3166Country\Iso3166Country Object
	(
		[iso3166Alpha2CountryCode:Iso3166Country\Iso3166Country:private] => DE
		[iso3166Alpha3CountryCode:Iso3166Country\Iso3166Country:private] => DEU
		[iso3166NumericCountryCode:Iso3166Country\Iso3166Country:private] => 276
		[iso3166_2CountryCode:Iso3166Country\Iso3166Country:private] => DE
		[toplevelDomain:Iso3166Country\Iso3166Country:private] => de
		[unitedNationsCountryCode:Iso3166Country\Iso3166Country:private] => DE
		[name:Iso3166Country\Iso3166Country:private] => Deutschland
	)

```

---

### Validate whether a ISO3166 property is valid (existing)

[](#validate-whether-a-iso3166-property-is-valid-existing)

#### Whether the ISO3166Alpha2 country code 'de' exists

[](#whether-the-iso3166alpha2-country-code-de-exists)

```
$countryExists = Iso3166CountryInformation::validateIso3166Alpha2('de');

```

#### Whether the ISO3166Alpha3 country code 'deu' exists

[](#whether-the-iso3166alpha3-country-code-deu-exists)

```
$countryExists = Iso3166CountryInformation::validateIso3166Alpha3('deu');

```

#### Whether the ISO3166Numeric country code '276' exists

[](#whether-the-iso3166numeric-country-code-276-exists)

```
$countryExists = Iso3166CountryInformation::validateIso3166Numeric(276);

```

#### Whether the ISO3166-2 country code 'de' exists

[](#whether-the-iso3166-2-country-code-de-exists)

```
$countryExists = Iso3166CountryInformation::validateIso3166v2('de');

```

#### Whether the ISO3166 top level domain 'de' exists

[](#whether-the-iso3166-top-level-domain-de-exists)

```
$countryExists = Iso3166CountryInformation::validateToplevelDomain('de');

```

#### Whether the ISO3166 united nations identifier 'de' exists

[](#whether-the-iso3166-united-nations-identifier-de-exists)

```
$countryExists = Iso3166CountryInformation::validateUnitedNationsId('de');

```

##### All validation methods return a boolean value.

[](#all-validation-methods-return-a-boolean-value)

---

### Methods of the Iso3166Country class

[](#methods-of-the-iso3166country-class)

#### Creation of an object by country code

[](#creation-of-an-object-by-country-code)

```
use ChromaX\Iso3166Country\Iso3166CountryInformation;
use ChromaX\Iso3166Country\Iso3166Country;

$country = new Iso3166Country();
$country->loadByIso3166Alpha2CountryCode('DE');

```

#### Creation of a custom country information object

[](#creation-of-a-custom-country-information-object)

```
use Iso3166Country\Iso3166CountryInformation;
use Iso3166Country\Iso3166Country;

$utopia = array(
	Iso3166CountryInformation::ISO3166_ALPHA2 => 'UO',
	Iso3166CountryInformation::ISO3166_ALPHA3 => 'UTO',
	Iso3166CountryInformation::ISO3166_NUMERIC => 42,
	Iso3166CountryInformation::ISO3166_2 => 'UO',
	Iso3166CountryInformation::UNITED_NATIONS_ID => 'uo',
	Iso3166CountryInformation::TOP_LEVEL_DOMAIN => 'uo',
	Iso3166CountryInformation::NAME => 'Utopia'
);
$country = new Iso3166Country();
$country->loadByIso3166CountryInformation($utopia);

```

#### Getter for properties

[](#getter-for-properties)

```
$iso3166Alpha2 = $country->getIso3166Alpha2CountryCode();
$iso3166Alpha3 = $country->getIso3166Alpha3CountryCode();
$iso3166Numeric = $country->getIso3166NumericCountryCode();
$iso3166_2 = $country->getIso3166v2CountryCode();
$toplevelDomain = $country->getToplevelDomain();
$unitedNationsIdentifier = $country->getUnitedNationsId();
$name = $country->getName();

```

Contribution
------------

[](#contribution)

Contributing to our projects is always very appreciated.
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/chroma-x/php-iso3166-country-information/blob/master/CONTRIBUTING.md) document.**

License
-------

[](#license)

PHP ISO3166 Country Information is under the MIT license.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity66

Established project with proven stability

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 ~128 days

Recently: every ~435 days

Total

15

Last Release

1940d ago

Major Versions

1.0.3 → 2.0.02016-03-16

2.0.7 → 3.0.02016-07-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5921241?v=4)[Martin Brecht-Precht](/maintainers/bonscho)[@Bonscho](https://github.com/Bonscho)

---

Tags

commoncomposer-packagecountriescountry-codescountry-informationidentified-countriesiso3166php-librarycountry codeIso3166

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chroma-x-iso3166-country-information/health.svg)

```
[![Health](https://phpackages.com/badges/chroma-x-iso3166-country-information/health.svg)](https://phpackages.com/packages/chroma-x-iso3166-country-information)
```

###  Alternatives

[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[composer/class-map-generator

Utilities to scan PHP code and generate class maps.

197122.6M108](/packages/composer-class-map-generator)[tapp/filament-country-code-field

Filament country code field.

2017.6k1](/packages/tapp-filament-country-code-field)[sun/country

Sun Country is the package that helps you to get the country name &amp; dialing code by the country ISO 3166-1 Alpha-2 code.

1016.5k](/packages/sun-country)

PHPackages © 2026

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