alzpk/restcountries-php-api-wrapper

Restcountries.com API PHP wrapper

1.0.1 2022-07-25 15:53 UTC

This package is auto-updated.

Last update: 2025-02-25 21:36:12 UTC


README

Requirements

{
  "php": "^7.4|^8.0",
  "guzzlehttp/guzzle": "^7.4",
  "ext-json": "*"
}

Installation

composer require alzpk/restcountries-php-api-wrapper

Usage examples

$client = new \Alzpk\RestCountriesPhpApiWrapper\RestCountriesClient();

// Fetch all countries
$countries = $client->all();

// Fetch countries by searching names
$countries = $client->searchByName('Denmark');

Client Map

Method Params Example
all $client->all();
searchByName (string) Country name $client->searchByName('Denmark');
searchByCode (string) Country code $client->searchByCode('208');
searchByCodes (array) List of country codes $client->searchByCodes(['208', '209']);
searchByCurrency (string) Country currency $client->searchByCurrency('DKK');
searchByLanguage (string) Country language $client->searchByLanguage('da');
searchByCapital (string) Country capital $client->searchByCapital('Copenhagen');
searchByRegion (string) Country region $client->searchByRegion('Europe');
searchBySubregion (string) Country subregion $client->searchBySubregion('South');

More info

Check https://github.com/amatosg/restcountries for more info.