league/iso3166
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The league/iso3166 library is a PHP package specifically developed to provide ISO 3166-1 data. ISO 3166-1 is part of the ISO 3166 standard published by the International Organization for Standardization (ISO). This standard defines codes for the names of countries, dependent territories, and special areas of geographical interest. To be specific, it defines three sets of country codes, including ISO 3166-1 alpha-2 – two-letter country codes, ISO 3166-1 alpha-3 – three-letter country codes, and ISO 3166-1 numeric – three-digit country codes. The library hence gives you access to these country codes in a developer-friendly way, making it easier to include country-specific information in your PHP projects.
To use the league/iso3166 library in your PHP projects, you should first install it via composer, a widely used dependency manager for PHP. Installation can be accomplished by running the following command in your command-line interface:
$ composer require league/iso3166
Once installed, the library can be used to retrieve data about any country. Here are some examples of code usage:
Retrieve a country by name:
$data = (new League\ISO3166\ISO3166)->name('Netherlands');
Retrieve a country by ISO 3166-1 alpha-2 code:
$data = (new League\ISO3166\ISO3166)->alpha2('NL');
Retrieve a country by ISO 3166-1 alpha-3 code:
$data = (new League\ISO3166\ISO3166)->alpha3('NLD');
Retrieve a country by ISO 3166-1 numeric code:
$data = (new League\ISO3166\ISO3166)->numeric('528');
Each of these methods will return an associative array with details about the specified country.
The documentation of league/iso3166 can be found on the website of the PHP League at https://iso3166.thephpleague.com. The 'Using' section of the documentation provides a comprehensive guide on how to utilise this library to retrieve country data based on ISO 3166-1 codes. It also provides information about the structure of the data returned by the library's methods.