PHPackages                             rebilly/country - 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. rebilly/country

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

rebilly/country
===============

country

v1.1.3(2y ago)5488.3k↓61%1MITPHPPHP &gt;=7.3CI failing

Since Dec 8Pushed 2y ago17 watchersCompare

[ Source](https://github.com/Rebilly/country)[ Packagist](https://packagist.org/packages/rebilly/country)[ Docs](https://github.com/rebilly/country/)[ RSS](/packages/rebilly-country/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

[![Software License](https://camo.githubusercontent.com/a7e65aee57b11d28e4caff8b945729a66be0bb663f7f93bd24c5aa65699f148e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Latest Version on Packagist](https://camo.githubusercontent.com/3ce9cec5a01762ce5c02a3d76c9b7a8668614bd52747e303611a8494c96be4bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f526562696c6c792f636f756e7472792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Rebilly/country)[![Build Status](https://github.com/Rebilly/country/workflows/Tests/badge.svg)](https://github.com/Rebilly/country/actions)[![Coverage Status](https://camo.githubusercontent.com/78c29f7d7d1c4f5f882037dedcafc27ebc986fa97b082b21297cea9ac89ce87d/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f526562696c6c792f636f756e7472792e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/Rebilly/country?branch=main)

Country Project
===============

[](#country-project)

Overview
--------

[](#overview)

This project manages Country information as Value Objects.

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

[](#installation)

Simply add a dependency on `rebilly/country` to your project's `composer.json` file if you use [Composer](https://getcomposer.org/) to manage the dependencies of your project.

Classes / Objects
-----------------

[](#classes--objects)

#### Country

[](#country)

A value object representing a country.

The identifiers are ISO 3166-1 codes (alphabetic and numeric).

The currency values used are ISO 4217 codes.

#### CountryRepository

[](#countryrepository)

The Repository contains a collection of Country objects with the ability to find Countries based on several of the attributes.

#### AdministrativeArea

[](#administrativearea)

A value object representing a province/state/territory/region. Because there is inconsistent naming from country to country, we use the term Administrative Area.

The identifiers are ISO 3166-2 codes (alphabetic and numeric).

#### AdministrativeAreaRepository

[](#administrativearearepository)

The Repository contains a collection of AdministrativeArea objects with the ability to find AdministrativeAreas based on several of the attributes or by Country.

Usage
-----

[](#usage)

```
use Country\AdministrativeAreaRepository;
use Country\CountryRepository;

$countryRepository = new CountryRepository();
$administrativeAreaRepository = new AdministrativeAreaRepository($countryRepository);

// get a list of all countries
$countries = $countryRepository->findAll();

if ($countryRepository->hasWithIsoAlpha2('US')) {
    $usa = $countryRepository->findByIsoAlpha2('US');
    echo $usa->getCommonName(); // United States
    echo $usa->getOfficialName(); // United States of America

    // get a list of all US states
    $administrativeAreaRepository->findByCountry($usa);

    if ($administrativeAreaRepository->hasWithNameAndCountry('New York', $usa)) {
        $newYork = $administrativeAreaRepository->findByNameAndCountry('New York', $usa);
        echo $newYork->getCode(); // NY
    }
}
```

Tests
-----

[](#tests)

```
phpunit

```

Security
--------

[](#security)

If you discover a security vulnerability, please report it to security at rebilly dot com.

License
-------

[](#license)

The Country library is open-sourced under the [MIT License](./LICENSE) distributed with the software.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

5

Last Release

1088d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.1

v1.1.0PHP &gt;=7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1161871?v=4)[Adam Altman](/maintainers/adamaltman)[@adamaltman](https://github.com/adamaltman)

---

Top Contributors

[![slavcodev](https://avatars.githubusercontent.com/u/757721?v=4)](https://github.com/slavcodev "slavcodev (7 commits)")[![adamaltman](https://avatars.githubusercontent.com/u/1161871?v=4)](https://github.com/adamaltman "adamaltman (3 commits)")[![dortort](https://avatars.githubusercontent.com/u/1169721?v=4)](https://github.com/dortort "dortort (2 commits)")[![ashkarpetin](https://avatars.githubusercontent.com/u/400534?v=4)](https://github.com/ashkarpetin "ashkarpetin (1 commits)")[![justnero](https://avatars.githubusercontent.com/u/11618962?v=4)](https://github.com/justnero "justnero (1 commits)")[![lexerom](https://avatars.githubusercontent.com/u/6643942?v=4)](https://github.com/lexerom "lexerom (1 commits)")[![agalstian](https://avatars.githubusercontent.com/u/55399628?v=4)](https://github.com/agalstian "agalstian (1 commits)")

---

Tags

country

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/rebilly-country/health.svg)

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

###  Alternatives

[components/flag-icon-css

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

12.2k1.7M23](/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.7k8.0M62](/packages/rinvex-countries)[lipis/flag-icons

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

12.2k43.4k10](/packages/lipis-flag-icons)[dougsisk/laravel-country-state

Country &amp; state helper for Laravel.

1731.9M](/packages/dougsisk-laravel-country-state)[hellonico/acf-country

A country field for ACF.

12196.8k](/packages/hellonico-acf-country)[stidges/country-flags

A small package to convert a country code to the corresponding country flag emoji

29274.4k4](/packages/stidges-country-flags)

PHPackages © 2026

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