PHPackages                             hamedhaghi/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. [API Development](/categories/api)
4. /
5. hamedhaghi/countries

ActiveLibrary[API Development](/categories/api)

hamedhaghi/countries
====================

A PHP client for the RestCountries API

1.0.8(1y ago)18MITPHPPHP ^8.3

Since Dec 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hamedhaghi/countries-client)[ Packagist](https://packagist.org/packages/hamedhaghi/countries)[ RSS](/packages/hamedhaghi-countries/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (7)Versions (10)Used By (0)

Countries PHP Client
====================

[](#countries-php-client)

A PHP client for the [RestCountries API](https://restcountries.com/). This package simplifies interacting with the API by providing an object-oriented interface to retrieve country data.

Features
--------

[](#features)

- Fetch detailed information about countries.
- Support for caching to improve performance.
- Compatible with both legacy and modern PHP projects.

Requirements
------------

[](#requirements)

- PHP 7.0 or higher

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

[](#installation)

Install the package via Composer:

```
composer require hamedhaghi/countries
```

Usage Example
-------------

[](#usage-example)

```
require_once 'vendor/autoload.php';

use Hamed\Countries\Factory\CountryRepositoryFactory;

// Initialize the client
$factory = new CountryRepositoryFactory();

// Enable caching for faster responses (optional)
$factory = $factory->isCachable()
                   ->setCacheTTL(3600); // Cache expiration time in seconds

// Initialize the repository
$repository = $factory->init();

// Query country data
$countries = $repository->getAll();
$countries = $repository->getByCapital('Berlin');
$countries = $repository->getByCode('DE');
$countries = $repository->getByCurrency('euro');
$countries = $repository->getByDemonym('German');
$countries = $repository->getByFullName('Germany');
$countries = $repository->getByLanguage('German');
$countries = $repository->getByName('Germany');
$countries = $repository->getByRegion('Europe');
$countries = $repository->getBySubregion('Western Europe');
$countries = $repository->getByTranslation('Germany');

// Clear the cache
$factory->clearCache();
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance42

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Every ~0 days

Total

9

Last Release

504d ago

PHP version history (9 changes)1.0.0PHP ^7.0

1.0.1PHP ^7.1

1.0.2PHP ^7.2

1.0.3PHP ^7.3

1.0.4PHP ^7.4

1.0.5PHP ^8.0

1.0.6PHP ^8.1

1.0.7PHP ^8.2

1.0.8PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/97765645825ca481414473660eef6d9f06b3a9a389b209a22886ccc0c73905aa?d=identicon)[hamed07](/maintainers/hamed07)

---

Top Contributors

[![hamedhaghi](https://avatars.githubusercontent.com/u/13066724?v=4)](https://github.com/hamedhaghi "hamedhaghi (69 commits)")

---

Tags

composerpackagephp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[googleads/googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP

67410.3M25](/packages/googleads-googleads-php-lib)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[fschmtt/keycloak-rest-api-client-php

PHP client to interact with Keycloak's Admin REST API.

4684.7k2](/packages/fschmtt-keycloak-rest-api-client-php)

PHPackages © 2026

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