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

Abandoned → [jord-jd/php-countries](/?search=jord-jd%2Fphp-countries)Library[Utility &amp; Helpers](/categories/utility)

divineomega/php-countries
=========================

🌍 PHP Countries is a library that provides an elegant syntax to country data.

v4.0.0(3mo ago)733.3k↓47.5%32LGPL-3.0-onlyPHPPHP ^7.1||^8.0

Since Sep 14Pushed 3mo agoCompare

[ Source](https://github.com/Jord-JD/php-countries)[ Packagist](https://packagist.org/packages/divineomega/php-countries)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/divineomega-php-countries/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (16)Used By (2)

🌍 PHP Countries
===============

[](#-php-countries)

[![Build Status](https://camo.githubusercontent.com/c77b35e5174eeb0a3c30fe692b9d80fd50d917dc4efaa8b957044d275e5fb081/68747470733a2f2f7472617669732d63692e636f6d2f4a6f72642d4a442f7068702d636f756e74726965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Jord-JD/php-countries)[![Coverage Status](https://camo.githubusercontent.com/03e9be53816454f5fcb89c17e2999266820b14ed8ba73227b3a289421b2d4773/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4a6f72642d4a442f7068702d636f756e74726965732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Jord-JD/php-countries?branch=master)[![StyleCI](https://camo.githubusercontent.com/127476305d2c5bf613f981e45de19689537648f9cf6c390ee296ab74e1e7fc2f/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3134343535393530362f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/144559506)[![Packagist](https://camo.githubusercontent.com/09efdb0e515eb1f3c679353c3a13accaaf7ef6fad37ea7ed895ba8dd3d4fadec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f72642d6a642f7068702d636f756e74726965732e737667)](https://packagist.org/packages/jord-jd/php-countries/stats)

PHP Countries is a library that provides an elegant syntax to country data.

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

[](#installation)

You can install PHP Countries via Composer, as follows.

```
composer require jord-jd/php-countries

```

Usage
-----

[](#usage)

To use PHP Countries, you must create a new `Countries` object.

```
use JordJD\Countries\Countries;

$countries = new Countries;
```

You can then call various methods on this object, to get country data.

### Retrieving all countries

[](#retrieving-all-countries)

You can easily retrieve an array of all countries and iterate through them, as follows.

```
foreach($countries->all() as $country) {
    var_dump($country->name.' - '.$country->officialName);
}
```

### Retrieving country by name

[](#retrieving-country-by-name)

Country details can be retrieved from the country's official or common name.

```
var_dump($countries->getByName('United Kingdom'));

/*
object(JordJD\Countries\Country)#146 (17) {
  ["name"]=>
  string(14) "United Kingdom"
  ["officialName"]=>
  string(52) "United Kingdom of Great Britain and Northern Ireland"
  ["topLevelDomains"]=>
  array(1) {
    [0]=>
    string(3) ".uk"
  }
  ["isoCodeAlpha2"]=>
  string(2) "GB"
  ["isoCodeAlpha3"]=>
  string(3) "GBR"
  ["isoCodeNumeric"]=>
  string(3) "826"
  ["languages"]=>
  array(1) {
    [0]=>
    string(7) "English"
  }
  ["languageCodes"]=>
  array(1) {
    [0]=>
    string(3) "eng"
  }
  ["currencyCodes"]=>
  array(1) {
    [0]=>
    string(3) "GBP"
  }
  ["callingCodes"]=>
  array(1) {
    [0]=>
    string(2) "44"
  }
  ["capital"]=>
  string(6) "London"
  ["capitals"]=>
  array(1) {
    [0]=>
    string(6) "London"
  }
  ["region"]=>
  string(6) "Europe"
  ["subregion"]=>
  string(15) "Northern Europe"
  ["latitude"]=>
  int(54)
  ["longitude"]=>
  int(-2)
  ["areaInKilometres"]=>
  int(242900)
  ["nationality"]=>
    string(7) "British"
}
*/
```

### Retrieving country by ISO 3166-1 code

[](#retrieving-country-by-iso-3166-1-code)

You can get the data for a country by its ISO 3166-1 code. The 2 character, 3 character and numeric variations are all accepted.

```
var_dump($countries->getByIsoCode('USA'));

/*
object(JordJD\Countries\Country)#4693 (16) {
  ["name"]=>
  string(13) "United States"
  ["officialName"]=>
  string(24) "United States of America"
  // etc...
}
*/
```

### Retrieving country by language spoken

[](#retrieving-country-by-language-spoken)

Providing a language, will return an array of all countries in which that language is spoken. You can provide a language name or code.

```
var_dump($countries->getByLanguage('German'));

/*
array(5) {
  [0]=>
  object(JordJD\Countries\Country)#4913 (16) {
    ["name"]=>
    string(7) "Belgium"
    ["officialName"]=>
    // etc...
  }
  [1]=>
  object(JordJD\Countries\Country)#4883 (16) {
    ["name"]=>
    string(7) "Germany"
    ["officialName"]=>
    string(27) "Federal Republic of Germany"
    // etc...
  }
  [2]=>
  object(JordJD\Countries\Country)#4826 (16) {
    ["name"]=>
    string(13) "Liechtenstein"
    ["officialName"]=>
    string(29) "Principality of Liechtenstein"
    // etc...
  }
  [3]=>
  object(JordJD\Countries\Country)#4808 (16) {
    ["name"]=>
    string(10) "Luxembourg"
    ["officialName"]=>
    string(25) "Grand Duchy of Luxembourg"
    // etc...
  }
  [4]=>
  object(JordJD\Countries\Country)#4871 (16) {
    ["name"]=>
    string(7) "Namibia"
    ["officialName"]=>
    string(19) "Republic of Namibia"
    // etc...
  }
}
*/
```

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance82

Actively maintained with recent releases

Popularity34

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 91.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 ~219 days

Recently: every ~619 days

Total

15

Last Release

93d ago

Major Versions

v1.0.5 → v2.0.02018-08-13

v2.3.0 → v3.0.02026-02-14

v3.0.0 → v4.0.02026-02-14

PHP version history (2 changes)v1.0.0PHP ^7.0

v2.3.0PHP ^7.1||^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (33 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")[![kirsty-gasston](https://avatars.githubusercontent.com/u/12949343?v=4)](https://github.com/kirsty-gasston "kirsty-gasston (1 commits)")

---

Tags

countriescountry-codesgeographic-datageographyphpphp-library

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[ctidigital/magento2-configurator

Keep magento persistently configured using files

174317.4k](/packages/ctidigital-magento2-configurator)[comcast/php-legal-licenses

A utility to generate a Licenses file containing the full license text for every dependency in your project for legal purposes.

821.1M9](/packages/comcast-php-legal-licenses)[xfra35/f3-cron

Job scheduling for the PHP Fat-Free Framework

73107.5k](/packages/xfra35-f3-cron)[bagusindrayana/laravel-coordinate

get nearby location from eloquent laravel

3019.7k](/packages/bagusindrayana-laravel-coordinate)

PHPackages © 2026

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