chibifr / country-converter
A PHP package to convert a country ISO to country name and vice-versa.
Installs: 3 539
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
pkg:composer/chibifr/country-converter
Requires (Dev)
- phpunit/phpunit: 5.0.*
This package is not auto-updated.
Last update: 2025-10-11 23:54:03 UTC
README
A PHP package to convert a country ISO to country name and vice-versa.
Installation
To install this package, make sure you have composer. Then, require it:
composer require chibifr/country-converter
Usage
You can now use it really easily! After you required the package with composer, start using it:
Without Exception management
<?php // Require the composer's vendor autoload file require './vendor/autoload.php'; use ChibiFR\CountryConverter\Converter; // Create a new Converter object $converter = new Converter(); // Get a country name from its ISO code echo $converter->getCountryName('jp'); // will echo "Japan" // Get a country ISO code from its name echo $converter->getCountryCode('France'); // will echo "FR"
With Exception management
<?php // Require the composer's vendor autoload file require './vendor/autoload.php'; use ChibiFR\CountryConverter\Converter; // Create a new Converter object $converter = new Converter(); // Get a country name from its ISO code try { echo $converter->getCountryName('jp'); // will echo "Japan" } catch (InvalidCountryNameException $e) { die($e->getMessage()); } // Get a country ISO code from its name try { echo $converter->getCountryCode('France'); // will echo "FR" } catch (InvalidCountryCodeException $e) { die($e->getMessage()); }