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

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

djokodonev/php-countries-fork
=============================

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

1.1.3(2y ago)01.7kLGPL-3.0-onlyPHPPHP ^8.1

Since Mar 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/djokodonev/php-countries-fork)[ Packagist](https://packagist.org/packages/djokodonev/php-countries-fork)[ RSS](/packages/djokodonev-php-countries-fork/feed)WikiDiscussions master Synced 1mo ago

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

PHP Countries
=============

[](#php-countries)

[![Build Status](https://camo.githubusercontent.com/0c442e603ad3487979f904ad3e81123bb2ca197dfc0d0a0db840cc3aaeb8d0ac/68747470733a2f2f7472617669732d63692e6f72672f72617069647765626c74642f7068702d636f756e74726965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rapidwebltd/php-countries)[![Coverage Status](https://camo.githubusercontent.com/770159ccea629a8220c9e1beeccf0d39329edeef9e87aa5d59cbc867134381a6/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f72617069647765626c74642f7068702d636f756e74726965732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/rapidwebltd/php-countries?branch=master)[![StyleCI](https://camo.githubusercontent.com/995b61264b46fdbce35c7ac74f28a11476d5539b8f0cc205b2030f56e77c0377/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130333532323833322f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/103522832)

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 djokodonev/php-countries-fork

```

Usage
-----

[](#usage)

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

```
use RapidWeb\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(RapidWeb\Countries\Country)#4869 (16) {
  ["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"
  ["region"]=>
  string(6) "Europe"
  ["subregion"]=>
  string(15) "Northern Europe"
  ["latitude"]=>
  int(54)
  ["longitude"]=>
  int(-2)
  ["areaInKilometres"]=>
  int(242900)
}
*/
```

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

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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 ~528 days

Total

5

Last Release

858d ago

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

v1.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/01af7a7aa1bc0980c106784b274bbcc23b8119a75adf639cf1014a90f6571c69?d=identicon)[djokodonev](/maintainers/djokodonev)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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