PHPackages                             jonasraoni/tld-to-iso - 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. jonasraoni/tld-to-iso

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

jonasraoni/tld-to-iso
=====================

Maps top level domains (TLD) against countries using the ISO 3166-1 alpha-2 format and vice-versa.

1.0.0(4y ago)017MITPHPPHP &gt;=7.2.0

Since Jul 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jonasraoni/tld-to-iso)[ Packagist](https://packagist.org/packages/jonasraoni/tld-to-iso)[ Docs](http://github.com/jonasraoni/tld-to-iso)[ RSS](/packages/jonasraoni-tld-to-iso/feed)WikiDiscussions main Synced 3d ago

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

TLD &lt;=&gt; ISO
=================

[](#tld--iso)

Mappings from top level domains (TLDs) to ISO 3166-1 alpha-2 and vice-versa.

Usage
-----

[](#usage)

Install the package:

```
composer require jonasraoni/tld-to-iso

```

The package provides 2 separated mappings (just to decrease the amount of processing/bloat data loaded into memory):

- [JonasRaoni\\TldToIso\\IsoToTld](src/IsoToTld.php)
- [JonasRaoni\\TldToIso\\TldToIso](src/TldToIso.php)

Choose the one that fits your needs and call the static method `get`, it might return the right mapping or null if it's invalid.

```
use JonasRaoni\TldToIso\TldToIso;

echo 'UK = ' . TldToIso::get('UK');
```

Data Generation
---------------

[](#data-generation)

To regenerate the classes, ensure the submodules are updated, then call the [build.php](build.php) script (just a simple code generator) and it will overwrite the existing classes.

Data Source
-----------

[](#data-source)

- The list of countries/TLDs was retrieved from this link:  (the .csv is linked to this repository as a submodule). The list isn't complete, as it's missing IDN entries (e.g. `.рф`) and custom domains (e.g. `.barcelona`), but let it be... The [Wikipedia's entry](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Internationalized_country_code_top-level_domains) looks more complete, but I'll be unable to keep it synchronized.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

1761d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/32c66dd29e4133c60890fd5dede747fd8975f0036c5e1f56f99eb7ebb25ee5df?d=identicon)[jonasraoni](/maintainers/jonasraoni)

---

Top Contributors

[![jonasraoni](https://avatars.githubusercontent.com/u/361921?v=4)](https://github.com/jonasraoni "jonasraoni (1 commits)")

---

Tags

mappingcountrytldIso3166

### Embed Badge

![Health badge](/badges/jonasraoni-tld-to-iso/health.svg)

```
[![Health](https://phpackages.com/badges/jonasraoni-tld-to-iso/health.svg)](https://phpackages.com/packages/jonasraoni-tld-to-iso)
```

###  Alternatives

[components/flag-icon-css

A curated collection of all country flags in SVG — plus the CSS for easier integration.

12.0k1.6M23](/packages/components-flag-icon-css)[rinvex/countries

Rinvex Countries is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

1.7k7.4M48](/packages/rinvex-countries)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[jeremykendall/php-domain-parser

Public Suffix List and IANA Root Zone Database based Domain parsing implemented in PHP.

1.2k13.0M77](/packages/jeremykendall-php-domain-parser)[lipis/flag-icons

A curated collection of all country flags in SVG — plus the CSS for easier integration.

12.0k27.5k4](/packages/lipis-flag-icons)[cornford/googlmapper

An easy way to integrate Google Maps with Laravel.

457447.9k4](/packages/cornford-googlmapper)

PHPackages © 2026

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