PHPackages                             phpfacile/geocoding - 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. phpfacile/geocoding

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

phpfacile/geocoding
===================

Service mainly aimed at retrieving coordinates (latitude, longitude) of a location (address, place).

1.0.2(7y ago)023↓100%MITPHPPHP &gt;=7.0.0

Since Nov 7Pushed 7y agoCompare

[ Source](https://github.com/phpfacile/geocoding)[ Packagist](https://packagist.org/packages/phpfacile/geocoding)[ Docs](https://github.com/phpfacile/geocoding)[ RSS](/packages/phpfacile-geocoding/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (9)Versions (4)Used By (0)

PHPFacile! Geocoding
====================

[](#phpfacile-geocoding)

This is mainly aimed at retrieving coordinates (latitude, longitude) of a location (address, place).

It is based on geocoder-php () and tries to use the provider matching our requirements:

- The provider must allow geocoding output storage
- The provider usage must be free (for few queries)

REM: A cache is used so as to meet as far as possible usage limitation defined by the providers

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

[](#installation)

At the root of your project type

```
composer require phpfacile/geocoding

```

Or add "phpfacile/geocoding": "^1.0" to the "require" part of your composer.json file

```
"require": {
    "phpfacile/geocoding": "^1.0"
}

```

Providers comparison
--------------------

[](#providers-comparison)

ProvidersStorage allowed?RestrictionsGeonamesYesNo more than 1 req/sGoogleMapfor 30 days maxMapBoxNoNominatimYesNo more than 1 req/sUsage
-----

[](#usage)

```
$geocodingService = new GeocodingService($cfg, $cacheDir);

$cfg = [
    'geonames' => [
        'username' => '',
    ],
    'nominatim' => [
        'rootUrl' => 'https://nominatim.openstreetmap.org',
        'userAgent' => '',
    ]
];

```

$cacheDir.'/nominatim' must exist (ex: if $cacheDir='/cache' then '/cache/nominatim' folder must exist and be writable)

Actually, in the current implementation, in any case **nominatim** is the preferred provider.

```
$locations = $this->geocodingService->getLocationsByAddress('Etretat, France');
foreach ($locations as $location) {
    var_dump($location);
}

$locations = $this->geocodingService->getPlacesByCountryAndPlaceName('France', 'Etretat');
foreach ($locations as $location) {
    var_dump($location);
}

```

Disclaimer
----------

[](#disclaimer)

Nominatim may stop its service at any moment

Troubleshooting
---------------

[](#troubleshooting)

If ever you modify the code so as to use geonames, you have to know that the following error message is silently ignored by the geonames provider ()

```
{"status":{"message":"user account not enabled to use the free webservice. Please enable it on your account page: http://www.geonames.org/manageaccount ","value":10}}

```

Todo
----

[](#todo)

- Manage localisation
- Remove unexpected (from a human point of view) results (for example, with nominatim, a query for "Paris, France" currently returns an entry with type="city" and an other entry almost identical but with type="administrative")

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Total

3

Last Release

2734d ago

### Community

Maintainers

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

---

Tags

geocodingplacelocationlatitudelongitudecoordinatescoords

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/phpfacile-geocoding/health.svg)

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

###  Alternatives

[anthonymartin/geo-location

Powerful GeoCoding library: Retrieve bounding box coordinates, distances between geopoints, point in polygon, get longitude and latitude from addresses and more with GeoLocation for PHP

196949.5k5](/packages/anthonymartin-geo-location)[data-values/geo

Geographical value objects, parsers and formatters

20631.0k18](/packages/data-values-geo)[php-coord/php-coord

PHPCoord is a PHP library to aid in handling coordinates. It can convert coordinates for a point from one system to another and also calculate distance between points.

110914.5k12](/packages/php-coord-php-coord)[jeroendesloovere/distance

Get distance between two locations using PHP.

3462.8k](/packages/jeroendesloovere-distance)[laravie/geotools

Geo-related tools PHP 7+ library

19105.4k1](/packages/laravie-geotools)[kolyunya/yii2-map-input-widget

Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly inteface.

2836.3k4](/packages/kolyunya-yii2-map-input-widget)

PHPackages © 2026

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