PHPackages                             yalesov/zf2-geoname - 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. yalesov/zf2-geoname

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

yalesov/zf2-geoname
===================

maintain a local copy of the Geonames database

v4.2.3(9y ago)12151[2 issues](https://github.com/yalesov/zf2-geoname/issues)ISCPHPPHP &gt;=5.3.3

Since Sep 17Pushed 9y ago2 watchersCompare

[ Source](https://github.com/yalesov/zf2-geoname)[ Packagist](https://packagist.org/packages/yalesov/zf2-geoname)[ Docs](https://github.com/yalesov/zf2-geoname)[ RSS](/packages/yalesov-zf2-geoname/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (10)Versions (26)Used By (0)

zf2-geoname
===========

[](#zf2-geoname)

[![Build Status](https://camo.githubusercontent.com/333a3036b67c5efef7bd5c10614f62d901b72976c6719e345b1607f326a08682/68747470733a2f2f7472617669732d63692e6f72672f79616c65736f762f7a66322d67656f6e616d652e737667)](https://travis-ci.org/yalesov/zf2-geoname)

Maintain a local copy of the [Geonames](http://geonames.org) (places) database.

This module will install a self-updating local copy of the Geonames (places) database. It covers the location information, as available from [the official database dump](http://download.geonames.org/export/dump/). It does not cover the "add-ons", e.g. earthquake, weather data, etc, as available from their webservices.

**Attention**: the Geonames database is around 1.5GiB - 2GiB in size, when installed in a MySQL database. Are you sure you need a local copy, instead of [the official webservices](http://www.geonames.org/export/ws-overview.html)?

Installation
============

[](#installation)

[Composer](http://getcomposer.org/):

```
{
  "require": {
    "yalesov/zf2-geoname": "4.*"
  }
}
```

Then add `Yalesov\Geoname` to the `modules` key in `(app root)/config/application.config.*`

Geoname module will also hook onto your application's database, through [`DoctrineORMModule`](https://github.com/doctrine/DoctrineORMModule). It will create a number of tables with the prefix `he_geoname_*`, and will use the default EntityManager `doctrine.entitymanager.orm_default`. If your settings are different, please modify the `doctrine` section of `config/module.config.yml` as needed.

Geoname module makes use of the [Cron module](https://github.com/yalesov/zf2-cron), so make sure you follow its settings, and have set up your cron job properly.

Finally, you need to update your database schema. The recommended way is through Doctrine's CLI:

```
$ vendor/bin/doctrine-module orm:schema-tool:update --force
```

Config
======

[](#config)

Copy `config/geoname.local.php.dist` to `(app root)/config/autoload/geoname.local.php`, and modify the settings.

- `tmpDir`: temporary directory for storing geonames database source files. (Make sure it is script-writable.)
- `cron`: (cron expression) how frequently Geoname should be run.

How frequent should `cron` be? The recommended setup is every 15 minutes, which is also the default. However, you can make your own adjustments:

At present (18 Sep 2012), it will take 820 cron jobs to install the database. At 15-minute intervals, that would take ~8.5 days to install the database. As for the updates, only 1 cron job per day is needed. However, setting more than one per day is highly recommended to provide redundancy - just in case the geonames server is temporarily unreachable, for example.

You can also adjust to a less frequent cron after install. The `status` field of the `Meta` entity, or the `he_geoname_meta` table, will be `Yalesov\Geoname\Repository\Meta::STATUS_INSTALL_*` during installation, and `Yalesov\Geoname\Repository\Meta::STATUS_UPDATE` afterwards.

Usage
=====

[](#usage)

Database sync
-------------

[](#database-sync)

Just follow the installation instructions. Geoname module will install and update its database in your cron jobs.

Note: when the sources indicate a "delete", Geoname module will not actually delete the corresponding record from your database; it will only mark it as deprecated (by setting the `isDeprecated` field to `true` in the entities `Place` and `AltName`). This is to ensure that you can rely on the primary IDs set up by Geoname module in your ZF2 app.

Querying the database
---------------------

[](#querying-the-database)

You can use the Doctrine 2 ORM API directly. Mapping files are located at `(zf2-geoname)/src/Yalesov/Geoname/Entity/Mapping`. All places' hierarchy, from `continent`, `country`, to the various administration levels, have been properly captured in the `parent` and `children` fields of the `Place` entity.

**TODO**: add a set of API for common tasks, e.g. finding a place by name, listing all places in a country, etc.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 90.9% 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 ~58 days

Recently: every ~0 days

Total

25

Last Release

3646d ago

Major Versions

0.2.0 → 1.0.02012-09-18

1.0.2 → 2.0.02012-09-19

2.0.2 → 3.0.02012-09-26

3.0.10 → v4.0.02016-07-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c284282a506ac3c908eda03eb11cc263a4457f2e3cc23cbe3e9b97830589e31?d=identicon)[yalesov](/maintainers/yalesov)

---

Top Contributors

[![yalesov](https://avatars.githubusercontent.com/u/20264293?v=4)](https://github.com/yalesov "yalesov (10 commits)")[![TomHAnderson](https://avatars.githubusercontent.com/u/493920?v=4)](https://github.com/TomHAnderson "TomHAnderson (1 commits)")

---

Tags

ZendFrameworkzf2geoname

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yalesov-zf2-geoname/health.svg)

```
[![Health](https://phpackages.com/badges/yalesov-zf2-geoname/health.svg)](https://phpackages.com/packages/yalesov-zf2-geoname)
```

###  Alternatives

[heartsentwined/zf2-cron

ZF2 cron module

596.8k](/packages/heartsentwined-zf2-cron)[slm/google-analytics

Google Analytics tracking integration for Zend Framework 2

4080.3k](/packages/slm-google-analytics)[akrabat/akrabat-session

A Zend Framework 2 module for configuring sessions

134.5k](/packages/akrabat-akrabat-session)

PHPackages © 2026

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