Laravel ISO3166 provides a convenient wrapper for the league/iso3166
library, allowing you to retrieve country information within your Laravel applications.
Install via Composer:
composer require vldmir/laravel-iso3166
If using Laravel <5.5, manually add service provider and facade:
'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
Run tests using PHPUnit:
vendor/bin/phpunit
Please see CHANGELOG for recent changes.
Contributions are welcome! Please see CONTRIBUTING for details.
If you discover any security issues, please email [email protected].
The MIT License (MIT). Please see LICENSE for details.