PHPackages                             rence/php-locations - 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. rence/php-locations

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

rence/php-locations
===================

A pure PHP package for working with Countries, Cities, Areas, Languages and Currencies data

v1.0.0(7mo ago)231MITPHPPHP ^8.2

Since Nov 11Pushed 7mo agoCompare

[ Source](https://github.com/DavidAbalaku/php-locations)[ Packagist](https://packagist.org/packages/rence/php-locations)[ RSS](/packages/rence-php-locations/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

PHP Locations
=============

[](#php-locations)

A pure PHP package for working with Countries, Cities, Areas, Languages and Currencies data.

The package provides a comprehensive database with location data that can be used in any PHP application:

- 250 Countries
- 5038 Cities (States/Regions)
- 149350 Areas (Cities part of a State/Region)
- Currencies
- Languages

All data is stored in JSON files and can be accessed through simple PHP classes.

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

[](#requirements)

- PHP 8.2 or higher

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

[](#installation)

Install via Composer:

```
composer require rence/php-locations
```

Usage
-----

[](#usage)

### Countries

[](#countries)

```
use PhpLocations\Models\Country;

// Get all countries
$countries = Country::all();

// Get only active countries
$activeCountries = Country::getActive();

// Find country by ID
$country = Country::find(1);

// Find country by ISO2 code
$country = Country::findByIso2('US');

// Find country by ISO3 code
$country = Country::findByIso3('USA');

// Access country properties
echo $country->name;
echo $country->iso2;
echo $country->currency;

// Get cities for a country
$cities = $country->getCities();
```

### Cities

[](#cities)

```
use PhpLocations\Models\City;

// Get all cities
$cities = City::all();

// Get active cities
$activeCities = City::getActive();

// Get cities by country ID
$cities = City::getByCountryId(1);

// Find city by ID
$city = City::find(1);

// Access city properties
echo $city->name;
echo $city->latitude;
echo $city->longitude;

// Get country for a city
$country = $city->getCountry();

// Get areas for a city
$areas = $city->getAreas();
```

### Areas

[](#areas)

```
use PhpLocations\Models\Area;

// Get all areas
$areas = Area::all();

// Get active areas
$activeAreas = Area::getActive();

// Get areas by city ID
$areas = Area::getByCityId(1);

// Get areas by country ID
$areas = Area::getByCountryId(1);

// Find area by ID
$area = Area::find(1);

// Access area properties
echo $area->name;

// Get city for an area
$city = $area->getCity();

// Get country for an area
$country = $area->getCountry();
```

### Currencies

[](#currencies)

```
use PhpLocations\Models\Currency;

// Get all currencies
$currencies = Currency::all();

// Get active currencies
$activeCurrencies = Currency::getActive();

// Find currency by ID
$currency = Currency::find(1);

// Find currency by ISO code
$currency = Currency::findByIso('USD');

// Access currency properties
echo $currency->name;
echo $currency->symbol;
echo $currency->iso;
```

### Languages

[](#languages)

```
use PhpLocations\Models\Language;

// Get all languages
$languages = Language::all();

// Find language by ID
$language = Language::find(1);

// Find language by ISO code
$language = Language::findByIso('en');

// Access language properties
echo $language->name;
echo $language->iso;
```

Data Structure
--------------

[](#data-structure)

All data is stored in JSON files located in the `database/data/` directory:

- `countries.json` - Country data
- `cities.json` - City data
- `areas.json` - Area data
- `currencies.json` - Currency data
- `languages.json` - Language data

You can also access the raw JSON data directly if needed.

License
-------

[](#license)

This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance62

Regular maintenance activity

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

234d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/111094927?v=4)[David Abalaku](/maintainers/DavidAbalaku)[@DavidAbalaku](https://github.com/DavidAbalaku)

---

Top Contributors

[![DavidAbalaku](https://avatars.githubusercontent.com/u/111094927?v=4)](https://github.com/DavidAbalaku "DavidAbalaku (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rence-php-locations/health.svg)

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

###  Alternatives

[thejano/laravel-domain-driven-design

Helps to use domain driven design within laravel

15425.2k](/packages/thejano-laravel-domain-driven-design)

PHPackages © 2026

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