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

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

alexconrad/enum-countries
=========================

v1.1.2-stable(2y ago)04MITPHPPHP &gt;=8.1

Since Dec 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/alexconrad/enum-countries)[ Packagist](https://packagist.org/packages/alexconrad/enum-countries)[ Docs](https://github.com/alexconrad/easy-mysql)[ RSS](/packages/alexconrad-enum-countries/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (8)Used By (0)

[![Test Coverage Badge](https://camo.githubusercontent.com/6aed27eefb7d2941e707b354a4aa14d74954b9699214512a623b0e0a65718903/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246676973742e67697468756275736572636f6e74656e742e636f6d253246616c6578636f6e7261642532463035386666373764316263353330643566613937376366393761373634373532253246726177253246656e756d2d636f756e74726965732d636f626572747572612d636f7665726167652e6a736f6e)](https://camo.githubusercontent.com/6aed27eefb7d2941e707b354a4aa14d74954b9699214512a623b0e0a65718903/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246676973742e67697468756275736572636f6e74656e742e636f6d253246616c6578636f6e7261642532463035386666373764316263353330643566613937376366393761373634373532253246726177253246656e756d2d636f756e74726965732d636f626572747572612d636f7665726167652e6a736f6e)[![Latest Stable Version](https://camo.githubusercontent.com/0ea2abf5de9594358e2fb23c736f8686cb9262088709d197374e91d1506db379/687474703a2f2f706f7365722e707567782e6f72672f616c6578636f6e7261642f656e756d2d636f756e74726965732f76)](https://packagist.org/packages/alexconrad/enum-countries)[![Total Downloads](https://camo.githubusercontent.com/048ca77663a4caadc366590d62fb4f1998ab7651e74cef6d09eac3e47a8fca42/687474703a2f2f706f7365722e707567782e6f72672f616c6578636f6e7261642f656e756d2d636f756e74726965732f646f776e6c6f616473)](https://packagist.org/packages/alexconrad/enum-countries)[![License](https://camo.githubusercontent.com/1e9c6c35d18b35adf8adfe60cb73cb42e5bf820a44fca81294f42a721b8cd018/687474703a2f2f706f7365722e707567782e6f72672f616c6578636f6e7261642f656e756d2d636f756e74726965732f6c6963656e7365)](https://packagist.org/packages/alexconrad/enum-countries)[![PHP Version Require](https://camo.githubusercontent.com/9112bee48ca339d8c25fa8e723f41061a8347036425965ed9f3ebf68595daa01/687474703a2f2f706f7365722e707567782e6f72672f616c6578636f6e7261642f656e756d2d636f756e74726965732f726571756972652f706870)](https://packagist.org/packages/alexconrad/enum-countries)

enum-countries
==============

[](#enum-countries)

Provides ENUM classes for ISO-3166-1 alpha2 and alpha3 country codes.

Installation

```
composer require alexconrad/enum-countries
```

Usage

```
use EnumCountriesIso3166\Country;
use EnumCountriesIso3166\CountryAlpha3;
use EnumCountriesIso3166\CountryService;

class MyClass
{
    public function __construct(
        private readonly CountryService $countryService
    ) {
    }

    public function save(Country $alpha2, CountryAlpha3 $alpha3, int $numericCode)
    {

        echo "ISO-3166-1 alpha2 Country Code:" . $alpha2->name . "\n";
        echo "ISO-3166-1 alpha3 Country Code:" . $alpha3->name . "\n";
        echo "ISO-3166-1 numeric Country Code:" . $numericCode . "\n";

        echo "Get country name from alpha2:" . $this->countryService->getName($alpha2) . "\n";
        echo "Get country name from alpha3:" . $this->countryService->getName($alpha3) . "\n";

        echo "Convert from alpha2 to alpha3:" . $this->countryService->alpha3($alpha2)->name . "\n";
        echo "Convert from alpha3 to alpha2:" . $this->countryService->alpha2($alpha3)->name . "\n";

        echo "Convert from alpha2 to numeric code:" . $this->countryService->numericCode($alpha2) . "\n";
        echo "Convert from alpha3 to numeric code:" . $this->countryService->numericCode($alpha3) . "\n";

    //From numeric code:
        echo "From numeric code to alpha2:" . $this->countryService->fromNumericCode($numericCode)->name . "\n";
    //From numeric code:
        echo "From numeric code to alpha3:" . $this->countryService->alpha3(
            $this->countryService->fromNumericCode($numericCode)
        )->name . "\n";
    }
}
```

Use your own country name

```
use EnumCountriesIso3166\Country;
use EnumCountriesIso3166\CountryAlpha3;
use EnumCountriesIso3166\CountryService;

class MyCountryService extends CountryService
{
    public function getName(Country|CountryAlpha3 $country): string
    {
        switch ($country) {
            case Country::FR:
            case CountryAlpha3::FRA:
                return "My own naming for France";
        }

        return parent::getName($country);
    }
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~0 days

Total

7

Last Release

871d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cb4cc73191660a73c9dfcc23772223eff2f57f0392b500aafe92f1cf13c8cde6?d=identicon)[alexconrad](/maintainers/alexconrad)

---

Top Contributors

[![alext-neurony](https://avatars.githubusercontent.com/u/170939568?v=4)](https://github.com/alext-neurony "alext-neurony (18 commits)")[![alexconrad](https://avatars.githubusercontent.com/u/4181562?v=4)](https://github.com/alexconrad "alexconrad (9 commits)")

---

Tags

enum countries

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[josegonzalez/cakephp-environments

CakePHP plugin to handle environments-level configuration

4785.9k](/packages/josegonzalez-cakephp-environments)

PHPackages © 2026

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