laravel-iso3166 maintained by vldmir
Description
A Laravel wrapper for the league/iso3166 package.
Author
Last update
2024/10/11 18:20
(dev-main)
License
Downloads
12
Tags
Laravel ISO3166
Laravel ISO3166 provides a convenient wrapper for the league/iso3166 library, allowing you to retrieve country information within your Laravel applications.
Installation
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,
],
Usage
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
Testing
Run tests using PHPUnit:
vendor/bin/phpunit
Changelog
Please see CHANGELOG for recent changes.
Contributing
Contributions are welcome! Please see CONTRIBUTING for details.
Security
If you discover any security issues, please email vld.romantsov@gmail.com.
Credits
License
The MIT License (MIT). Please see LICENSE for details.