PHPackages                             coldcoder/laravel-worldcities - 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. coldcoder/laravel-worldcities

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

coldcoder/laravel-worldcities
=============================

A Laravel package to retrieve cities in the world

0.1.1(7y ago)51.9k5[3 issues](https://github.com/solaz3/laravel-worldcities/issues)[1 PRs](https://github.com/solaz3/laravel-worldcities/pulls)MITPHPPHP ^7.0

Since May 2Pushed 3y ago2 watchersCompare

[ Source](https://github.com/solaz3/laravel-worldcities)[ Packagist](https://packagist.org/packages/coldcoder/laravel-worldcities)[ RSS](/packages/coldcoder-laravel-worldcities/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

Add models for retrieving world countries, states and cities in Laravel app
===========================================================================

[](#add-models-for-retrieving-world-countries-states-and-cities-in-laravel-app)

Brand new world country/state/city database according to your locale settings.

As I was developing a cascaded dropdown of countries, state and cities selection, I found a package named [khsing/laravel-world](https://github.com/khsing/laravel-world), but this package seems not maintain for a long time, so I've forked it and changed a little to fix some issues. Because of its data structure, it is a little diffcult to retrieve locale data with eagerly loading. So I develop this package which implemented [spatie/laravel-translatable](https://github.com/spatie/laravel-translatable) so it can get data by your locale with no pain.

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

[](#requirements)

This package requires Laravel 5.5 or higher, PHP 7.0 or higher and a database that supports `json` fields such as MySQL 5.7 or higher.

if you are using Mariadb, pls make sure the version &gt; 10.2.8 which supports json field, and use [ybr-nx/laravel-mariadb](https://github.com/ybr-nx/laravel-mariadb) as your database driver

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

[](#installation)

You can install the package via composer:

```
composer require coldcoder/laravel-worldcities
```

The package will automatically register itself for laravel &gt;= 5.5.

You can register the service provider in config/app.php manually if using laravel &lt; 5.5

You can publish the migration with:

```
php artisan vendor:publish --provider="Coldcoder\WorldCity\WorldCityServiceProvider"
```

After that the migration and seeds will be published for you, you can then create the tables of `world` structures and seeds by running the migration and seeds:

```
php artisan migrate
```

```
composer dump-autoload
php artisan db:seed --class=WorldsTablesSeeder
```

You can optionally publish the config file with:

```
php artisan vendor:publish --provider="Coldcoder\WorldCity\WorldCityServiceProvider" --tag="config"
```

You can config the table name in the published config file:

```
return [

    /*
     * define the table names for continent, country, state and city
     */
    'table' => [
        'continent' => 'worlds_continents',

        'country' => 'worlds_countries',

        'state' => 'worlds_states',

        'city' => 'worlds_cities',
    ],
];
```

Here are some code examples:

```
use Coldcoder\WorldCity\Models\Country;

// get a country by code
$usa = Country::findFromCode('us');
$usa->states;  // return states
$usa->cities;  // return cities
$usa->has_state; // return true;

// as it just implements locales of en and zh, you can translate other locales by yourself
// or request a PR
// translating a continent/country/state/city
$usa->setTranslation('name', 'fr', 'country name in French');
$usa->save();

// you can use HasCity trait within your own model to setup relationship
use Coldcoder\WorldCity\Traits\HasCity;

class YourModel extends Model
{
    use HasCity;
}

// after that you can get your model's related city
$model->city;
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance8

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

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 ~176 days

Total

2

Last Release

2758d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6195f66c8168a7d9921d6e65b18a03b19dc5a3be987031a87a6a06b22d13c907?d=identicon)[John Au](/maintainers/John%20Au)

---

Top Contributors

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

---

Tags

citylaravelphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coldcoder-laravel-worldcities/health.svg)

```
[![Health](https://phpackages.com/badges/coldcoder-laravel-worldcities/health.svg)](https://phpackages.com/packages/coldcoder-laravel-worldcities)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[illuminate/events

The Illuminate Events package.

13454.3M1.8k](/packages/illuminate-events)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.5M178](/packages/illuminate-broadcasting)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)

PHPackages © 2026

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