1. Go to this page and download the library: Download farzai/geonames library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
farzai / geonames example snippets
use Farzai\Geonames\Client;
// Create a new client
$client = new Client();
// Get all countries and return $resource
$resource = $client->getCountryInfo(); // \Farzai\Geonames\Resource\CollectionResource
// Now, you can access the data using the following methods:
$countries = $resource->asArray(); // Array
$json = $resource->asJson(); // String
// Or acccess data as entity
foreach ($resource->all() as $country) {
/** @var \Farzai\Geonames\Entities\CountryEntity $country */
echo $country->name;
}