alchemy/geonames-api-consumer

A connector to a geonames server

4.1.0 2018-04-12 18:21 UTC

This package is auto-updated.

Last update: 2024-10-08 17:50:58 UTC


README

Build Status

This is a consumer for the GeonamesServer.

Usage

  • Connector creation :
$connector = ALchemy\Geonames\Connector::create($serverUrl);
  • Query cities :
// returns an array of Alchemy\Geonames\Geoname objects
$geonames = $connector->search('Paris');

Query options :

// limit to 50 results
// use '89.73.4.152' as IP address for closeness sort
$connector->search('Paris', 50, '89.73.4.152');
  • Find by IP :
// returns a Alchemy\Geonames\Geoname object
$geoname = $connector->ip('89.73.4.152');
  • Find a GeonameId :
// returns a Alchemy\Geonames\Geoname object
$geoname = $connector->geoname(2988507);

Silex Service Provider

$app = new Silex\Application();
$app->register(new Alchemy\Geonames\GeonamesServiceProvider(), array(
    'geonames.server-uri' => 'http://geonames.domain.tld',  // mandatory parameter
));

License

This project is released under the MIT License.