PHP code example of vldmir / laravel-iso3166

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

    

vldmir / laravel-iso3166 example snippets


'providers' => [
    Vldmir\LaravelIso3166\Providers\CountryServiceProvider::class,
],
'aliases' => [
    'CountryService' => Vldmir\LaravelIso3166\Facades\CountryService::class,
],

use CountryService;

// Retrieve country by name
$country = CountryService::getByName('Canada');
echo $country->name;    // Canada
echo $country->alpha2;  // CA

// Retrieve country by alpha-2 code
$country = CountryService::getByAlpha2('US');
echo $country->name;    // United States of America

// Retrieve country by numeric code
$country = CountryService::getByNumeric('124');
echo $country->name;    // Canada