PHPackages                             maxh/php-nominatim - 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. maxh/php-nominatim

ActiveLibrary[API Development](/categories/api)

maxh/php-nominatim
==================

Wrapper for Nominatim API

2.3.0(4y ago)51411.1k↓53.5%14[2 issues](https://github.com/maxhelias/php-nominatim/issues)2MITPHPPHP &gt;=7.3CI failing

Since Nov 22Pushed 4y ago4 watchersCompare

[ Source](https://github.com/maxhelias/php-nominatim)[ Packagist](https://packagist.org/packages/maxh/php-nominatim)[ Docs](https://github.com/maxhelias/php-nominatim)[ RSS](/packages/maxh-php-nominatim/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (4)Versions (14)Used By (2)

Wrapper Nominatim API
=====================

[](#wrapper-nominatim-api)

[![Latest Stable Version](https://camo.githubusercontent.com/0a7ef58aa109636f78c91f885ef1b81faa3cf1ccc834372c3b2d66bc592e3b38/68747470733a2f2f706f7365722e707567782e6f72672f6d6178682f7068702d6e6f6d696e6174696d2f762f737461626c65)](https://packagist.org/packages/maxh/php-nominatim)[![Build Status](https://camo.githubusercontent.com/782f88da7ff341da5957c2448b3c4772caace9bc268a13840238dbbbda3a8e81/68747470733a2f2f7472617669732d63692e636f6d2f6d617868656c6961732f7068702d6e6f6d696e6174696d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/maxhelias/php-nominatim)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/de1f6343df20915031140ca4d4c888a490f8fbf6a84f0b6e2368d2dd5aaaff41/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617868656c6961732f7068702d6e6f6d696e6174696d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/maxhelias/php-nominatim/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/d5f7a295e8027a7f3e4ca07f9e964db0e85faf4bcd9f2fe8e6e8fe6e66241719/68747470733a2f2f706f7365722e707567782e6f72672f6d6178682f7068702d6e6f6d696e6174696d2f646f776e6c6f616473)](https://packagist.org/packages/maxh/php-nominatim)[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/maxhelias/php-nominatim/blob/master/LICENSE)

[![SensioLabsInsight](https://camo.githubusercontent.com/134ee2be2535b47604f8d3c53b27d92e2ed667fd37c26fff25daea4a291304e5/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f63353465353531392d303166642d343835352d393830662d3361323863356636666631322f6269672e706e67)](https://insight.sensiolabs.com/projects/c54e5519-01fd-4855-980f-3a28c5f6ff12)

A simple interface to OSM Nominatim.

See [Nominatim documentation](http://wiki.openstreetmap.org/wiki/Nominatim) for info on the service.

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

[](#installation)

Install the package through [composer](http://getcomposer.org):

```
composer require maxh/php-nominatim
```

Make sure, that you include the composer [autoloader](https://getcomposer.org/doc/01-basic-usage.md#autoloading)somewhere in your codebase.

Basic usage
-----------

[](#basic-usage)

Create a new instance of Nominatim.

```
use maxh\Nominatim\Nominatim;

$url = "http://nominatim.openstreetmap.org/";
$nominatim = new Nominatim($url);
```

Searching by query :

```
$search = $nominatim->newSearch();
$search->query('HelloWorld');

$nominatim->find($search);
```

Or break it down by address :

```
$search = $nominatim->newSearch()
            ->country('France')
            ->city('Bayonne')
            ->postalCode('64100')
            ->polygon('geojson')    //or 'kml', 'svg' and 'text'
            ->addressDetails();

$result = $nominatim->find($search);
```

Or do a reverse query :

```
$reverse = $nominatim->newReverse()
            ->latlon(43.4843941, -1.4960842);

$result = $nominatim->find($reverse);
```

Or do a lookup query :

```
$lookup = $nominatim->newLookup()
            ->format('xml')
            ->osmIds('R146656,W104393803,N240109189')
            ->nameDetails(true);

$result = $nominatim->find($lookup);
```

Or do a details query (by place\_id):

```
$details = $nominatim->newDetails()
            ->placeId(1234)
            ->polygon('geojson');

$result = $nominatim->find($details);
```

Or do a details query (by osm type and osm id):

```
$details = $nominatim->newDetails()
            ->osmType('R')
            ->osmId(1234)
            ->polygon('geojson');

$result = $nominatim->find($details);
```

By default, the output format of the request is json and the wrapper return a array of results. It can be also xml, but the wrapper return a object [SimpleXMLElement](http://php.net/manual/fr/simplexml.examples-basic.php)

How to override request header ?
--------------------------------

[](#how-to-override-request-header-)

There are two possibilities :

1. By `Nominatim` instance, for all request :

```
$nominatim = new Nominatim($url, [
    'verify' => false
]);
```

2. By `find` method, for a request :

```
$result = $nominatim->find($lookup, [
    'verify' => false
]);
```

How to customize HTTP client configuration ?
--------------------------------------------

[](#how-to-customize-http-client-configuration-)

You can inject your own HTTP client with your specific configuration. For instance, you can edit user-agent and timeout for all your requests

```
