{"id":15939430,"url":"https://github.com/maxhelias/php-nominatim","last_synced_at":"2025-05-06T23:46:52.318Z","repository":{"id":52850744,"uuid":"71013129","full_name":"maxhelias/php-nominatim","owner":"maxhelias","description":":satellite: Wrapper for Nominatim API","archived":false,"fork":false,"pushed_at":"2021-07-17T14:17:32.000Z","size":1004,"stargazers_count":48,"open_issues_count":2,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T13:03:15.293Z","etag":null,"topics":["composer","nominatim","php","wrapper"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxhelias.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-15T20:58:43.000Z","updated_at":"2025-03-01T14:24:14.000Z","dependencies_parsed_at":"2022-08-23T08:21:50.688Z","dependency_job_id":null,"html_url":"https://github.com/maxhelias/php-nominatim","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhelias%2Fphp-nominatim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhelias%2Fphp-nominatim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhelias%2Fphp-nominatim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhelias%2Fphp-nominatim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxhelias","download_url":"https://codeload.github.com/maxhelias/php-nominatim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788409,"owners_count":21804282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","nominatim","php","wrapper"],"created_at":"2024-10-07T06:04:31.416Z","updated_at":"2025-05-06T23:46:52.290Z","avatar_url":"https://github.com/maxhelias.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Wrapper Nominatim API\n================\n\n[![Latest Stable Version](https://poser.pugx.org/maxh/php-nominatim/v/stable)](https://packagist.org/packages/maxh/php-nominatim)\n[![Build Status](https://travis-ci.com/maxhelias/php-nominatim.svg?branch=master)](https://travis-ci.com/maxhelias/php-nominatim)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/maxhelias/php-nominatim/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/maxhelias/php-nominatim/?branch=master)\n[![Total Downloads](https://poser.pugx.org/maxh/php-nominatim/downloads)](https://packagist.org/packages/maxh/php-nominatim)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/maxhelias/php-nominatim/blob/master/LICENSE)\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/c54e5519-01fd-4855-980f-3a28c5f6ff12/big.png)](https://insight.sensiolabs.com/projects/c54e5519-01fd-4855-980f-3a28c5f6ff12)\n\nA simple interface to OSM Nominatim.\n\n\nSee [Nominatim documentation](http://wiki.openstreetmap.org/wiki/Nominatim) for info on the service.\n\nInstallation\n------------\n\nInstall the package through [composer](http://getcomposer.org):\n\n```bash\ncomposer require maxh/php-nominatim\n```\n\nMake sure, that you include the composer [autoloader](https://getcomposer.org/doc/01-basic-usage.md#autoloading)\nsomewhere in your codebase.\n\nBasic usage\n-----------\n\nCreate a new instance of Nominatim.\n\n```php\nuse maxh\\Nominatim\\Nominatim;\n\n$url = \"http://nominatim.openstreetmap.org/\";\n$nominatim = new Nominatim($url);\n```\n\nSearching by query :\n\n```php\n$search = $nominatim-\u003enewSearch();\n$search-\u003equery('HelloWorld');\n\n$nominatim-\u003efind($search);\n```\n\nOr break it down by address :\n\n```php\n$search = $nominatim-\u003enewSearch()\n            -\u003ecountry('France')\n            -\u003ecity('Bayonne')\n            -\u003epostalCode('64100')\n            -\u003epolygon('geojson')    //or 'kml', 'svg' and 'text'\n            -\u003eaddressDetails();\n\n$result = $nominatim-\u003efind($search);\n```\n\nOr do a reverse query :\n\n```php\n$reverse = $nominatim-\u003enewReverse()\n            -\u003elatlon(43.4843941, -1.4960842);\n\n$result = $nominatim-\u003efind($reverse);\n```\n\nOr do a lookup query :\n\n```php\n$lookup = $nominatim-\u003enewLookup()\n            -\u003eformat('xml')\n            -\u003eosmIds('R146656,W104393803,N240109189')\n            -\u003enameDetails(true);\n\n$result = $nominatim-\u003efind($lookup);\n```\n\nOr do a details query (by place_id):\n\n```php\n$details = $nominatim-\u003enewDetails()\n            -\u003eplaceId(1234)\n            -\u003epolygon('geojson');\n\n$result = $nominatim-\u003efind($details);\n```\n\nOr do a details query (by osm type and osm id):\n\n```php\n$details = $nominatim-\u003enewDetails()\n            -\u003eosmType('R')\n            -\u003eosmId(1234)\n            -\u003epolygon('geojson');\n\n$result = $nominatim-\u003efind($details);\n```\n\nBy default, the output format of the request is json and the wrapper return a array of results. \nIt can be also xml, but the wrapper return a object [SimpleXMLElement](http://php.net/manual/fr/simplexml.examples-basic.php)\n\nHow to override request header ?\n--------------------------------\n\nThere are two possibilities :\n\n1. By `Nominatim` instance, for all request :\n```php\n$nominatim = new Nominatim($url, [\n    'verify' =\u003e false\n]);\n```\n2. By `find` method, for a request :\n````php\n$result = $nominatim-\u003efind($lookup, [\n    'verify' =\u003e false\n]);\n````\n\nHow to customize HTTP client configuration ?\n--------------------------------------------\n\nYou can inject your own HTTP client with your specific configuration. For instance, you can edit user-agent and timeout for all your requests\n\n```php\n\u003c?php\nuse maxh\\Nominatim\\Nominatim;\nuse GuzzleHttp\\Client;\n\n$url = \"http://nominatim.openstreetmap.org/\";\n$defaultHeader = [\n    'verify' =\u003e false,\n    'headers', array('User-Agent' =\u003e 'api_client')\n];\n\n$client = new Client([\n    'base_uri'           =\u003e $url,\n    'timeout'            =\u003e 30,\n    'connection_timeout' =\u003e 5,\n]);\n\n$nominatim = new Nominatim($url, $defaultHeader, $client);\n```\n\nNote\n----\n\nThis projet was inpired by the [Opendi/nominatim](https://github.com/opendi/nominatim) project with more features like reverse query, support of the xml format, customize HTTP client and more on which i work.\n\nRecall Usage Policy Nominatim \n-----------------------------\n\nIf you use the service : [http://nominatim.openstreetmap.org/](http://nominatim.openstreetmap.org/), please see [Nominatim usage policy](http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxhelias%2Fphp-nominatim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxhelias%2Fphp-nominatim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxhelias%2Fphp-nominatim/lists"}