This is a consumer for the GeonamesServer.
- 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);
$app = new Silex\Application();
$app->register(new Alchemy\Geonames\GeonamesServiceProvider(), array(
'geonames.server-uri' => 'http://geonames.domain.tld', // mandatory parameter
));
This project is released under the MIT License.