Download the PHP package farzai/geonames without Composer

On this page you can find all versions of the php package farzai/geonames. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package geonames

GeoNames data for PHP and Laravel

Latest Version on Packagist Tests Total Downloads

Countries, first- and second-level administrative divisions, cities and postal codes from GeoNames, read from the verified snapshots Farzai publishes at https://data.farzai.com/geonames/. Plain PHP, with first-class Laravel support.

Upgrading from 2.x: 3.0 is a rewrite. The downloader, the converters (including MongoDB) and the --feature-class option are gone. See UPGRADING.md.

Requirements

Install

Countries, the feature-kind table and time zones ship with the package (about 310 KB), so Geonames::countries() works at once. Everything else is fetched on demand.

Fetch data

Option Meaning
--datasets=a,b admin1, admin2, cities, alternate_names, postal_codes, or all (default admin1,admin2,cities)
--sqlite also fetch each country's SQLite file
--snapshot=ID a snapshot id, or latest (default: the snapshot this release is pinned to)
--path=DIR the store directory (default $GEONAMES_PATH, else ~/.cache/farzai-geonames)

Reading never touches the network. If the data you ask for is not in the store, you get a NotFetchedException that names the command to run.

Plain PHP (and everything else)

Testing with a fake

In Laravel, Geonames::swap() also rebinds GeonamesRepository in the container, which the facade, the rules and the casts read.

Laravel

Package discovery registers the service provider and the Geonames facade alias.

Validation

String rules do the same: geonames_country, geonames_admin1:country, geonames_city:country, geonames_postal_code:country.

Rule Passes when
geonames_country the value is an ISO 3166-1 alpha-2, alpha-3 or numeric code
geonames_admin1:field the value is an admin1 code (50) of the country in field; without a field it must be TH.50
geonames_city:field the value is a city geoname_id, in the country in field when given
geonames_postal_code:field the value matches the country's postal-code pattern; ->mustExist() also requires a row in the fetched postal file

Eloquent casts

Migrations and seeder

Tables: geonames_countries, geonames_admin1, geonames_admin2, geonames_cities, geonames_postal_codes, geonames_alternate_names (names are configurable in config/geonames.php; publish it with --tag=geonames-config).

Configuration

Key Env Default
geonames.path GEONAMES_PATH storage/app/geonames
geonames.snapshot GEONAMES_SNAPSHOT null: the snapshot this release is pinned to. fetch --snapshot=latest downloads that snapshot, but reads stay on the pin until you set this
geonames.base_url GEONAMES_BASE_URL https://data.farzai.com/geonames/v1

What is in the data

Dataset Rows (snapshot 2026-10-16.1) Notes
countries 252 bundled; ISO codes, currency, calling code, languages, neighbours
admin1 3,865 one global file; keyed by geoname_id and geonames_code
admin2 47,641 per country
cities 236,262 places with population 500 or more, or an administrative seat; population_tier 15000, 5000, 1000 or 500
postal_codes 4,102,707 in 120 countries per country; precision full or partial
alternate_names 1,478,335 per country; lang, preferred, short, colloquial, historic

Ids are geoname_id (plus wikidata_id where GeoNames links one). Admin divisions are keyed by their own geoname_id; ISO 3166-2 is a nullable attribute. Time zones are IANA names; coordinates are WGS84 with five decimals. The schema is data/schema.json, and the data rules (null is unknown, ignore unknown fields and enum values) are those of schema 1. Refreshes are monthly.

Data licence and attribution

The data is from GeoNames and is licensed under CC BY 4.0. If you show it, say:

Data from GeoNames (geonames.org), licensed under CC BY 4.0

and note that it was converted (to JSON, NDJSON and SQLite), limited to places with a population of 500 or more or an administrative seat, with names selected by language, coordinates rounded to five decimals, and kinds and population tiers added. Postal codes come from GeoNames' postal dump, which states CC BY 4.0 (its readme links the 3.0 URL; the snapshot manifest records that). Great Britain's full postal codes carry: "Contains Royal Mail data © Royal Mail copyright and database right 2022. Source: Office for National Statistics licensed under the Open Government Licence v.3.0." Every snapshot's manifest.json lists the licence of each source; data/snapshot.json repeats the credits for the pinned one. The data is provided as is, without warranty of accuracy, timeliness or completeness.

The package code is MIT licensed.

Testing

Maintainers

php tools/update-bundled-data.php latest moves the pin and the bundled files to the newest published snapshot; a test checks that the bundled files match the pinned manifest.


All versions of geonames with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-json Version *
ext-zlib Version *
illuminate/collections Version ^12.0 || ^13.0
illuminate/contracts Version ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package farzai/geonames contains the following files

Loading the files please wait ...