PHP code example of smart / geo

1. Go to this page and download the library: Download smart/geo 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/ */

    

smart / geo example snippets


$countryCollection = (new Geo)->getCountryRepository()->findAll();

foreach ($countryCollection as $country) {
   echo $country->getNames()->get('en');
}

$countryCollection->orderByName();

$geo = new Geo;
$country = $geo->getCountryRepository()->findByCode('US');
$regionCollection = (new Geo)->getRegionRepository()->findByCountry($country);

foreach ($regionCollection as $region) {
   echo $region->getNames()->get('en') . " is a " . 
       $region->getType()::class . " of the " . 
       $country->getNames()->get('en);
}
shell
php vendor/bin/geo data:update