PHPackages                             tocaan/world - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. tocaan/world

ActiveLaravel-package[Localization &amp; i18n](/categories/localization)

tocaan/world
============

Laravel countries, states, cities and currencies

3.1.8(3y ago)12981MITPHPPHP &gt;=7.4

Since Jan 22Pushed 3y agoCompare

[ Source](https://github.com/Tocaanco/world)[ Packagist](https://packagist.org/packages/tocaan/world)[ Docs](https://github.com/Tocaanco/world.git)[ RSS](/packages/tocaan-world/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (31)Used By (0)

[![Laravel world](./logo.jpg)](./logo.jpg)

The World is a Laravel package which provides a list of the countries, states, cities, timezones, currencies and languages.

It can be consumed with the World Facade or the defined Api routes.

### Installation

[](#installation)

```
composer require tocaan/world

php artisan vendor:publish --tag=world

php artisan migrate

php artisan db:seed --class=WorldSeeder

```

### Upgrading to v1.1.12?

[](#upgrading-to-v1112)

- New addition: `search` argument.
- New addition: The allowed countries and disallowed countries arrays in config. This new addition by @aeq-dev is to help restrict the seeding of the countries and their dependencies.
- If you are upgrading from a version older than 1.1.10 and due to the changes in the routes and config files, re-publish the package assets by issuing the command `php artisan vendor:publish --tag=world --force`
- If needed, customize the table names and enable or disabled the optional database fields in the `world.php` config file.
- The counties table sub\_region field was renamed to subregion. It is advisable to refresh the migrations and seed the db tables.

### Changelog

[](#changelog)

Please read [CHANGELOG](CHANGELOG.md) for more information of what was changed recently.

### Contributing

[](#contributing)

Please read [CONTRIBUTING](CONTRIBUTING.md) for more details.

### Demo

[](#demo)

Please feel free to query

Examples

[https://laravel-world.com/api/states?filters\[country\_code\]=RO&amp;fields=cities](https://laravel-world.com/api/states?filters%5Bcountry_code%5D=RO&fields=cities)

### Usage

[](#usage)

#### List all the countries.

[](#list-all-the-countries)

Use the World facade

```
use Nnjeim\World\World;

$action =  World::countries();

if ($action->success) {

	$countries = $action->data;
}

response
{
	"success": true,
	"message": "countries",
	"data": [
		{
			"id": 1,
			"name": "Afghanistan"
		},
		{
			"id": 2,
			"name": "Åland Islands"
		},
		.
		.
		.
	],
}

```

Use the Api countries endpoint

```
https://myDomain.local/api/countries

```

#### Fetch a country with its states and cities.

[](#fetch-a-country-with-its-states-and-cities)

Use the World facade

```
use Nnjeim\World\World;

$action =  World::countries([
	'fields' => 'states,cities',
	'filters' => [
		'iso2' => 'FR',
	]
]);

if ($action->success) {

	$countries = $action->data;
}

response
{
	"success": true,
	"message": "countries",
	"data": [
		"id": 77,
		"name": "France",
		"states": [
			 {
				"id": 1271,
				"name": "Alo"
			},
			{
				"id": 1272,
				"name": "Alsace"
			},
			.
			.
			.
		],
		"cities": [
			{
				"id": 25148,
				"name": "Abondance"
			},
			{
				"id": 25149,
				"name": "Abrest"
			},
			.
			.
			.
		]
	],
}

```

Use the Api countries endpoint

```
https://myDomain.local/api/countries?fields=states,cities&filters[iso2]=FR

```

#### List all the cities by country id.

[](#list-all-the-cities-by-country-id)

```
use Nnjeim\World\WorldHelper;

protected $world;

public function __construct(WorldHelper $world) {

	$this->world = $world;
}

$action = $this->world->cities([
	'filters' => [
		'country_id' => 182,
	],
]);

if ($action->success) {

	$cities = $action->data;
}

```

Use the Api cities endpoint

```
https://myDomain.local/api/cities?filters[country_code]=RO

```

### Available actions

[](#available-actions)

NameDescriptioncountrieslists all the world countriesstateslists all the statescitieslists all the citiestimezoneslists all the timezonescurrencieslists all the currencieslanguageslists all the languagesAn action response is formed as below:

- success (boolean)
- message (string)
- data (instance of Illuminate\\Support\\Collection)
- errors (array)

#### Countries action

[](#countries-action)

- fields\*: comma seperated string(countries table fields in addition to states, cities, currency and timezones).
- filters\*: array of keys(countries table fields) and their corresponding values.
- search\*: string.

#### States action

[](#states-action)

- fields\*: comma seperated string(states table fields in addition to country and states).
- filters\*: array of keys(states table fields) and their corresponding values.
- search\*: string.

#### Cities action

[](#cities-action)

- fields\*: comma seperated string(cities table fields in addition to country and state).
- filters\*: array of keys(cities table fields) and their corresponding values.
- search\*: string.

#### Timezones action

[](#timezones-action)

- fields\*: comma seperated string(timezones table fields in addition to country).
- filters\*: array of keys(timezones table fields) and their corresponding values.
- search\*: string.

#### Currencies action

[](#currencies-action)

- fields\*: comma seperated string(currencies table fields in addition to country).
- filters\*: array of keys(currencies table fields) and their corresponding values.
- search\*: string.

#### Languages action

[](#languages-action)

- fields\*: comma seperated string(languages table fields).
- filters\*: array of keys(languages table fields) and their corresponding values.
- search\*: string.

### Available Api routes

[](#available-api-routes)

All routes can be prefixed by any string. Ex admin, api, api ...

#### Countries

[](#countries)

MethodGETRoute/{prefix}/countriesParameters\*comma seperated fields(countries table fields in addition to states, cities, currency and timezones), array filters, string searchExample/api/countries?fields=iso2,cities&amp;filters\[phone\_code\]=44responsesuccess, message, data#### States

[](#states)

MethodGETRoute/{prefix}/statesParameters\*comma seperated fields(states table fields in addition to country and cities), array filters, string searchExample/api/states?fields=country,cities&amp;filters\[country\_code\]=ROresponsesuccess, message, data#### Cities

[](#cities)

MethodGETRoute/{prefix}/citiesParameters\*comma seperated fields(states table fields in addition to country and state), array filters, string searchExample/api/cities?fields=country,state&amp;filters\[country\_code\]=ROresponsesuccess, message, data#### Timezones

[](#timezones)

MethodGETRoute/{prefix}/timezonesParameters\*comma seperated fields(states table fields in addition to the country), array filters, string searchExample/api/timezones?fields=country&amp;filters\[country\_code\]=ROresponsesuccess, message, data#### Currencies

[](#currencies)

MethodGETRoute/{prefix}/currenciesParameters\*comma seperated fields(states table fields in addition to the country), array filters, string searchExample/api/timezones?fields=country&amp;filters\[country\_code\]=ROresponsesuccess, message, data#### Languages

[](#languages)

MethodGETRoute/{prefix}/languagesParameters\*comma seperated fields, string searchExample/api/languages?fields=dirresponsesuccess, message, data### Localization

[](#localization)

The available locales are ar, bn, br, de, en, es, fr, ja, kr, nl, pl, pt, ro, ru and zh.
The default locale is en.
Include in the request header

```
accept-language=locale

```

Alternativley, you can use specific locale with the `World` Facade `setLocale('locale')` helper method. Example:

```
World::setLocale('zh')->countries();

```

### Schema

[](#schema)

[![](./schema.jpg)](./schema.jpg)

### Configuration

[](#configuration)

The configuration of the world package is in the world.php config file.
If you are upgrading from a previous version, you should consider re-publishing the file by issuing:

```
php artisan vendor:publish --tag=world --force

```

#### Supported Locales

[](#supported-locales)

A list of the accepted locales which relate to the localized lang files.

#### Modules enablement

[](#modules-enablement)

The states, cities, timezones, currencies and languages modules can be optionally disabled.
Please note that the cities module depends on the states module.

#### Routes

[](#routes)

If you don't wish to use the packages as an api service, you can disable all the routes by assigning false to routes.

#### Migrations

[](#migrations)

It offers the ability to enable or disable the database fields.
When changing this configuration the database should be dropped and the seeder should be re-run.

### Testing

[](#testing)

Requirements

- The database is seeded.
- The database connection is defined in the .env file.

Browse to the package root folder and run:

```
composer install //installs the package dev dependencies
composer test
```

`* optional`

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 61.5% 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 ~12 days

Recently: every ~3 days

Total

30

Last Release

1231d ago

Major Versions

1.1.12 → 2.0.02022-06-03

2.0.6 → 3.0.02022-11-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/22634d946ccae8799787bebcd8ea49cb4df8936e767c8acf972d990e3e0e8b8b?d=identicon)[tocaan](/maintainers/tocaan)

---

Top Contributors

[![nnjeim](https://avatars.githubusercontent.com/u/78922079?v=4)](https://github.com/nnjeim "nnjeim (56 commits)")[![MostafaSewidan](https://avatars.githubusercontent.com/u/35866891?v=4)](https://github.com/MostafaSewidan "MostafaSewidan (22 commits)")[![Ivanshamir](https://avatars.githubusercontent.com/u/29983451?v=4)](https://github.com/Ivanshamir "Ivanshamir (3 commits)")[![aeq-dev](https://avatars.githubusercontent.com/u/81385994?v=4)](https://github.com/aeq-dev "aeq-dev (3 commits)")[![emiliopedrollo](https://avatars.githubusercontent.com/u/6577541?v=4)](https://github.com/emiliopedrollo "emiliopedrollo (3 commits)")[![gdevlugt](https://avatars.githubusercontent.com/u/1107080?v=4)](https://github.com/gdevlugt "gdevlugt (2 commits)")[![cloudchristoph](https://avatars.githubusercontent.com/u/204027?v=4)](https://github.com/cloudchristoph "cloudchristoph (1 commits)")[![parth391](https://avatars.githubusercontent.com/u/4966579?v=4)](https://github.com/parth391 "parth391 (1 commits)")

---

Tags

laravellumencountriesstatescurrenciestimezonescities

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tocaan-world/health.svg)

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

###  Alternatives

[nnjeim/world

Laravel countries, states, cities, currencies, languages and IP geolocation

970361.2k3](/packages/nnjeim-world)[pragmarx/countries

PHP Countries and Currencies

1.9k3.3M18](/packages/pragmarx-countries)[pragmarx/countries-laravel

Countries for Laravel

1471.1M2](/packages/pragmarx-countries-laravel)[pharaonic/laravel-locations

Laravel - Countries\[States/Cities, Currency, Phone Code, Languages, Capital\] &amp; Continents &amp; Timezones.

102.4k1](/packages/pharaonic-laravel-locations)

PHPackages © 2026

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