PHPackages                             slivka-b/laravel-geonames - 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. [Database &amp; ORM](/categories/database)
4. /
5. slivka-b/laravel-geonames

ActiveLibrary[Database &amp; ORM](/categories/database)

slivka-b/laravel-geonames
=========================

\[fork\] The package allows integrating geonames database with a Laravel application.

0.1.1(3y ago)085MITPHPPHP ^8.1

Since Mar 21Pushed 3y agoCompare

[ Source](https://github.com/SviatoslavBereznitskyi/laravel-geonames)[ Packagist](https://packagist.org/packages/slivka-b/laravel-geonames)[ RSS](/packages/slivka-b-laravel-geonames/feed)WikiDiscussions master Synced 1mo ago

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

🌎 Laravel Geonames
==================

[](#-laravel-geonames)

**Currently the work in progress. It will receive updates with possible breaking changes. Not recommended using in production environments yet.**

The package allows integrating geonames database with a Laravel application.

🗒️ Description
--------------

[](#️-description)

**This package is a fork of nevadskiy/laravel-geonames.**

The package is very useful for applications that rely on the geo data.

By default, the package provides 5 tables: `continents`, `countries`, `divisions`, `cities` and `translations` and fills them with data from the [geonames](https://www.geonames.org/) service.

It also allows to keep the data **up-to-date**, so the package fetches all daily modifications provided by the [geonames](https://www.geonames.org/) service and use them to synchronize your own database.

You can also set up the package to seed only data that belongs to specific countries, disable unneeded tables, set up minimal population filter and use your own custom models.

Translations are powered by the [imcity-tech/laravel-translatable](https://github.com/imcity-tech/laravel-translatable).

🔌 Installation
--------------

[](#-installation)

```
composer require imcity-tech/laravel-geonames
```

✅ Requirements
--------------

[](#-requirements)

- Laravel `9.0` or newer
- PHP `8.0` or newer

🔨 Usage
-------

[](#-usage)

### Default structure and behaviour

[](#default-structure-and-behaviour)

- Migrate the database

```
php artisan migrate
```

- Run insert process

```
php artisan geonames:insert
```

It will insert download and insert the geonames dataset into your database.

> Note that the insert process may take some time. On average, it is about 15 minutes (without downloading time).

### Schedule updates

[](#schedule-updates)

Add the following code to your console kernel (`app/Console/Kernel.php`) if you want to receive geonames daily updates.

```
protected function schedule(Schedule $schedule)
{
    $schedule->command('geonames:update')->dailyAt('4:00');
}
```

> Note, that time is specified for the `UTC` timezone, so if you run server on another timezone, you need to convert time according to it.

### Configure custom structure

[](#configure-custom-structure)

If you want to configure package according to your needs, you need to publish the package configuration first.

```
php artisan vendor:publish --tag=geonames-config

```

#### Specifying source

[](#specifying-source)

You can choose appropriate data source for seeding as one of `SOURCE_ALL_COUNTRIES`, `SOURCE_SINGLE_COUNTRY` or `SOURCE_ONLY_CITIES`.

The default is `SOURCE_ALL_COUNTRIES` that indicates to fetch data from the [allCountries.zip](http://download.geonames.org/export/dump/) file. It contains all 4 models (`continents`, `countries`, `divisions` and `cities`). You can configure [filters](#specifying-filters) in the `geonames` configuration file to specify [countries](#countries-filter) that is going to be seeded and [minimal population](#population-filter).

The `SOURCE_SINGLE_COUNTRY` source is used to fetch data from country-based files (e.g. [US.zip](http://download.geonames.org/export/dump/)). The `continents` table will not be seeded with this source. You can specify which country (or countries) you are going to seed specifying [countries filter](#countries-filter) in the `geonames` configuration file.

The `SOURCE_ONLY_CITIES` source is used to fetch data from city-based files (e.g. [cities500.zip](http://download.geonames.org/export/dump/)). There is only `cities` table available with this source type. You can specify [minimal population filter](#population-filter) to indicate which file it is going to fetch by population. It is also possible to use countries filter to seed cities that belongs only to specific countries.

#### Specifying filters

[](#specifying-filters)

By default, there are two filters which you can use to filter data being seeded.

#### Countries filter

[](#countries-filter)

The `countries` filter is used to filter data that belongs only to specific country (or countries). If the `SOURCE_SINGLE_COUNTRY` [source](#specifying-source) is specified, this filter will be used to download a country-based data source. The default is `*` that indicates that all countries are allowed. Multiple countries can be specified as an array of ISO country codes.

Example:

```
'filters' => [
    'countries' => ['AU', 'US']
]
```

#### Population filter

[](#population-filter)

The `population` filter is used to filter cities by the indicated minimal population. If the `SOURCE_ONLY_CITIES` [source](#specifying-source) is specified, this filter will be used to download a city-based data source. Any value from `0` and higher has be used, but in combination with the `SOURCE_ONLY_CITIES` source, available values are only `500`, `1000`, `5000` and `15000`.

Example:

```
'filters' => [
    'population' => 15000
]
```

#### Overriding models

[](#overriding-models)

Most likely you will need your own models with their own behaviour and relations instead of provided ones by default.

To override them, use `models` key in the `geonames` configuration file.

If you are not going to use any model, you can switch the value to `false` and then corresponding tables will not be migrated at all.

For example, most applications probably will not need continent model.

```
'models' => [
    'continent' => false,
    'country' => App\Models\Country::class,
    'division' => App\Models\Division::class,
    'city' => App\Models\City::class,
],
```

#### Overriding migrations

[](#overriding-migrations)

To rename tables or remove unnecessary fields, you can publish migrations and edit them before execution migrations command.

- To publish default migrations, use the following command:

```
php artisan vendor:publish --tag=geonames-migrations

```

- Then disable default migrations from being migrated, setting `default_migrations` to `false` in the `geonames` configuration file.

```
'default_migrations' => false
```

#### Inserting custom structure

[](#inserting-custom-structure)

- After configuring [source](#specifying-source) and [filters](#specifying-filters), you can execute migrations command. It will determine which tables should be migrated and create them in the database.

```
php artisan migrate
```

- Then you can run insert command.

```
php artisan geonames:insert
```

#### Reinserting dataset

[](#reinserting-dataset)

Sometimes you may need to delete all data and reinsert it again. To do it, pass the `--reset` option to `geonames:insert` command.

```
php artisan geonames:insert --reset
```

📑 Changelog
-----------

[](#-changelog)

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

☕ Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for more information.

🔓 Security
----------

[](#-security)

If you discover any security related issues, please [e-mail me](mailto:nevadskiy@gmail.com) instead of using the issue tracker.

📜 License
---------

[](#-license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.1% 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

2

Last Release

1149d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/593a292c66ea42e04d10ede2b2706869fea2df13f7ac3dc766c83e26a7699fec?d=identicon)[SviatoslavBereznitskyi](/maintainers/SviatoslavBereznitskyi)

---

Top Contributors

[![xalaida](https://avatars.githubusercontent.com/u/31131784?v=4)](https://github.com/xalaida "xalaida (309 commits)")[![imClement](https://avatars.githubusercontent.com/u/293105?v=4)](https://github.com/imClement "imClement (12 commits)")[![SviatoslavBereznitskyi](https://avatars.githubusercontent.com/u/37864596?v=4)](https://github.com/SviatoslavBereznitskyi "SviatoslavBereznitskyi (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![Xmk](https://avatars.githubusercontent.com/u/1087368?v=4)](https://github.com/Xmk "Xmk (1 commits)")

---

Tags

laraveldatabasecountriesgeocitiesgeonames

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/slivka-b-laravel-geonames/health.svg)

```
[![Health](https://phpackages.com/badges/slivka-b-laravel-geonames/health.svg)](https://phpackages.com/packages/slivka-b-laravel-geonames)
```

###  Alternatives

[nevadskiy/laravel-geonames

Populate your database using the GeoNames service.

2715.1k](/packages/nevadskiy-laravel-geonames)[aternus/geonames-client

GeoNames API Client

39215.5k2](/packages/aternus-geonames-client)[altwaireb/laravel-world

Laravel World, Countries States Cities DB Migration &amp; Seeder

989.4k](/packages/altwaireb-laravel-world)[waad/laravel-model-metadata

A robust Laravel package for handling metadata with JSON casting, custom relation names, and advanced querying capabilities.

823.1k](/packages/waad-laravel-model-metadata)

PHPackages © 2026

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