1. Go to this page and download the library: Download namnv609/php-rest-countries 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/ */
namnv609 / php-rest-countries example snippets
use NNV\RestCountries;
$restCountries = new RestCountries;
$restCountries->all();
$restCountries->byName("viet");
// or with full name
$restCountries->byName("vietnam", true);
// Single country code
$restCountries->byCodes("vn");
// Multiple country codes
$restCountries->byCodes(["vn", "cn", "th"]);
$restCountries->byCurrency("vnd");
$restCountries->byLanguage("vi");
$restCountries->byCapitalCity("hanoi");
$restCountries->byCallingCode("84");
$restCountries->byRegion("asia");
$restCountries->byRegionalBloc("asean");
// You can use `fields([])` with any available methods
$restCountries->fields(["name", "callingCodes", "capital"])->all();
$restCountries->fields(["name"])->byName("vietnam", true);
$restCountries->fields(["callingCodes"])->byRegionalBloc("asean");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.