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

ActiveLibrary[API Development](/categories/api)

michaeldrennen/geonames
=======================

A Laravel (php) package that interfaces with the geolocation services on geonames.org.

v13.3.0(1mo ago)9514.1k↓88.9%42MITPHPPHP ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4 || ^8.5CI failing

Since Feb 15Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/michaeldrennen/Geonames)[ Packagist](https://packagist.org/packages/michaeldrennen/geonames)[ RSS](/packages/michaeldrennen-geonames/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (10)Dependencies (28)Versions (39)Used By (0)

geonames v13.x
==============

[](#geonames-v13x)

[![Latest Stable Version](https://camo.githubusercontent.com/17a502025a24139e58284a0c4d543b2631281d854afc14f81ab8939a36fa68c9/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6472656e6e656e2f67656f6e616d65732f76657273696f6e)](https://packagist.org/packages/michaeldrennen/geonames) [![Total Downloads](https://camo.githubusercontent.com/0aadf1cadca39956f5c377050e92fdaef6f87c6d07ec89afb753c919b7de42fd/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6472656e6e656e2f67656f6e616d65732f646f776e6c6f616473)](https://packagist.org/packages/michaeldrennen/geonames) [![License](https://camo.githubusercontent.com/51b8fe10daa5455cd26e6e7fdf3482cf0b63fce87d8e2ef17ed627170e79c69b/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6472656e6e656e2f67656f6e616d65732f6c6963656e7365)](https://packagist.org/packages/michaeldrennen/geonames) [![GitHub issues](https://camo.githubusercontent.com/9a07c3326db99885c03e0cc6bb40de51dd286a551d6a0e266a01f399a6b37be6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d69636861656c6472656e6e656e2f47656f6e616d6573)](https://github.com/michaeldrennen/Geonames/issues) [![GitHub forks](https://camo.githubusercontent.com/669928e4a2307a4c771978324f0c405adce15a8870c1b7126bd87de3d1f71ed3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6d69636861656c6472656e6e656e2f47656f6e616d6573)](https://github.com/michaeldrennen/Geonames/network) [![GitHub stars](https://camo.githubusercontent.com/24669536834a8eadb84937dc9006f16076149b63ea72efc241ea5039226d4ca8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6d69636861656c6472656e6e656e2f47656f6e616d6573)](https://github.com/michaeldrennen/Geonames/stargazers)

A Laravel (php) package to interface with the geo-location services at geonames.org.

Major Version Jump
------------------

[](#major-version-jump)

I jumped several major versions to catch up with Larvel's major version number. Makes things a little clearer.

Notes
-----

[](#notes)

There is still a lot that needs to be done to make this package "complete". I've gotten it to a point where I can use it for my next project. As time allows, I will improve the documentation and testing that comes with this package. Thanks for understanding.

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

[](#installation)

```
composer require michaeldrennen/geonames

```

Since Laravel 5.5, the package will automatically register itself via package discovery.

If you're using an older version or have discovery disabled, add the `geonames` provider to the `providers` array in your `config/app.php` config file:

```
MichaelDrennen\Geonames\GeonamesServiceProvider::class,
```

After that, Run migrate command:

```
php artisan migrate

```

To publish package files, run:

```
php artisan vendor:publish --provider="MichaelDrennen\Geonames\GeonamesServiceProvider"

```

Want to install all of the geonames records for the US, Canada, and Mexico as well as pull in the feature codes definitions file in English?

```
php artisan geonames:install --country=US --country=CA --country=MX --language=en
```

Want to just install everything in the geonames database?

```
php artisan geonames:install
```

**To download `cities1000.zip` along with all country data:**

```
php artisan geonames:install --country="*" --country="cities1000.zip"
```

**To download only `cities1000.zip`:**

```
php artisan geonames:install --country="cities1000.zip"
```

Adding Countries Incrementally
------------------------------

[](#adding-countries-incrementally)

If you have already installed a set of countries (e.g., US and CA) and wish to add more countries (e.g., BR) without reinstalling the entire dataset, you can use the `geonames:add` command:

```
php artisan geonames:add --country=BR
```

This command will:

- Download only the necessary data files for the specified new countries.
- Append new geonames records and alternate names to your existing tables.
- Update your `GeoSetting` to reflect the newly added countries.
- Reload smaller, non-country-specific tables like `admin-1-code`, `admin-2-code`, `feature-code`, and `feature-class` to ensure consistency.

You can specify multiple countries:

```
php artisan geonames:add --country=BR --country=AR
```

Maintenance
-----------

[](#maintenance)

Now that you have the geonames database up and running on your system, you need to keep it up-to-date.

I have an update script that you need to schedule in Laravel to run every day.

Some info on how to schedule Laravel artisan commands:

You can read this notice at:

`The "last modified" timestamp is in Central European Time. `

It looks like geonames updates their data around 3AM CET.

So if you schedule your system to run the geonames:update artisan command after 4AM CET, you should be good to go.

I like to keep my servers running on GMT. Keeps things consistent.

(Central European Time is 1 hour ahead of Greenwich Mean Time)

Assuming your servers are running on GMT, your update command would look like:

```
$schedule->command('geonames:update')->dailyAt('3:00');
```

The update artisan command will handle the updates and deletes to the geonames table.

By default, `GeonamesServiceProvider` will run it for you daily at `config('geonames.update_daily_at')`. You can change it in your `.env` file using `GEONAMES_UPDATE_DAILY_AT` key or in `config/geonames.php` file (if you have published it).

Country Info Table
------------------

[](#country-info-table)

This package now includes functionality to download and import detailed country information from geonames.org's `countryInfo.txt` file. This data is stored in the `countryinfo` table.

To install this data, you can either:

1. **Run it as part of the main installation:** The `geonames:install` command now automatically includes the country info data.

    ```
    php artisan geonames:install
    ```

    or with specific options:

    ```
    php artisan geonames:install --country=US --language=en
    ```
2. **Run the command directly:** If you need to install only the country information or re-import it, you can use the dedicated command:

    ```
    php artisan geonames:countryinfo
    ```

    If you need to overwrite existing country info data, use the `--force` option:

    ```
    php artisan geonames:countryinfo --force
    ```

Gotchas
-------

[](#gotchas)

Are you getting something like: 1071 Specified key was too long

@see

Add this to your AppServiceProvider.php file:

```
Schema::defaultStringLength(191);
```

A quick word on indexes
-----------------------

[](#a-quick-word-on-indexes)

This library contains a bunch of migrations that contain a bunch of indexes. Now not everyone will need all of the indexes.

So when you install this library, run the migrations and delete the indexes that you don't need.

Also, Laravel doesn't let you specify a key length for indexes on varchar columns. There are two indexes suffering from this limit. Instead of creating indexes on those columns the "Laravel way", I send a raw/manual query to create the indexes with the proper lengths.

###  Health Score

65

—

FairBetter than 99% of packages

Maintenance89

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity93

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 94.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 ~91 days

Recently: every ~22 days

Total

38

Last Release

57d ago

Major Versions

v3.0.1 → v7.0.02020-06-21

v7.0.3 → v8.0.02021-07-03

v8.0.0 → v9.0.02023-04-29

v9.1.0 → v12.0.02026-02-10

v12.0.0 → v13.0.02026-05-08

PHP version history (7 changes)v1.0.0PHP ^7.1

v2.x-devPHP ^7.3

v7.0.2PHP ^7.2.5

v8.0.0PHP ^7.0|^8.0

v9.0.0PHP ^7.0 || ^8.0 || ^8.1

v9.1.0PHP ^8.0 || ^8.1 || ^8.2 || ^8.3

v12.0.0PHP ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4 || ^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/b701baeed9e105a4a117e363b478d932306516c9365b4f2e3ef2dfed358f608b?d=identicon)[michaeldrennen](/maintainers/michaeldrennen)

---

Top Contributors

[![michaeldrennen](https://avatars.githubusercontent.com/u/5288190?v=4)](https://github.com/michaeldrennen "michaeldrennen (272 commits)")[![leonid-chernyavskiy](https://avatars.githubusercontent.com/u/60206382?v=4)](https://github.com/leonid-chernyavskiy "leonid-chernyavskiy (7 commits)")[![karlshea](https://avatars.githubusercontent.com/u/40136?v=4)](https://github.com/karlshea "karlshea (4 commits)")[![simonschaufi](https://avatars.githubusercontent.com/u/941794?v=4)](https://github.com/simonschaufi "simonschaufi (2 commits)")[![victorlap](https://avatars.githubusercontent.com/u/1645632?v=4)](https://github.com/victorlap "victorlap (1 commits)")[![maherelgamil](https://avatars.githubusercontent.com/u/6294478?v=4)](https://github.com/maherelgamil "maherelgamil (1 commits)")[![mikrahub](https://avatars.githubusercontent.com/u/14978471?v=4)](https://github.com/mikrahub "mikrahub (1 commits)")[![0xAliRaza](https://avatars.githubusercontent.com/u/33368198?v=4)](https://github.com/0xAliRaza "0xAliRaza (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/michaeldrennen-geonames/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M146](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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