limanweb/iso-codes is a Laravel package for country, currency and other iso codes for laravel.
It currently has 0 GitHub stars and 6 downloads on Packagist (latest version v1.0).
Install it with composer require limanweb/iso-codes.
Discover more Laravel packages by limanweb
or browse all Laravel packages to compare alternatives.
Last updated
This package provides any ISO-code lists to use in your Laravel-application.
List of sections and available locales:
en, fr, ru, ka, hyen, ru, kaRun command:
composer require "limanweb/iso-codes"
Add service provider class to provider section of your config/app.php
Limanweb\IsoCodes\Providers\IsoCodesServiceProvider::class,
Add alias for facade to alias section of your config/app.php
'IsoCodes' => Limanweb\IsoCodes\Services\IsoCodesServiceFacade::class,
Run command:
php artisan vendor:publish
and input index number of Limanweb\IsoCodes\Providers\IsoCodesServiceProvider provider.
Service Limanweb\IsoCodes\Service\IsoCodesService provides a method get() to get any data.
You can access to service throught facade alias \IsoCodes
Syntax:
\IsoCode::get($section, $path = null, $locale = null)
Arguments:
To get full country list put iso_country section name into first argument
>>> IsoCodes::get('iso_country')
=> [
"AFG" => [
"alpha2" => "AF",
"alpha3" => "AFG",
"num" => 4,
"title" => "Afghanistan",
],
"ALB" => [
"alpha2" => "AL",
"alpha3" => "ALB",
"num" => 8,
"title" => "Albania",
],
...
]
To get one country item you can put second argument
>>> IsoCodes::get('iso_country','USA')
=> [
"alpha2" => "US",
"alpha3" => "USA",
"num" => 840,
"title" => "United States of America (the)",
]
By default title translates to current application locale. Use third argument to get data in other locale (if it available).
>>> IsoCodes::get('iso_country','USA', 'ru')
=> [
"alpha2" => "US",
"alpha3" => "USA",
"num" => 840,
"title" => "США",
]
To get full currency list put iso_currency section name into first argument
>>> IsoCodes::get('iso_currency')
=> [
"AED" => [
"alpha" => "AED",
"num" => 784,
"minor_unit" => 2,
"title" => "United Arab Emirates dirham",
],
"AFN" => [
"alpha" => "AFN",
"num" => 971,
"minor_unit" => 2,
"title" => "Afghan afghani",
],
...
]
Service class is singleton and has only one instance in application.
Service use two level cache to store compiled (translated) data. First level (L1) cache is a service class property with one request processing lifetime. And second level (L2) cache is a system cache.
You can disable using of cache with use_cache and use_local_cache options in config/limanweb/iso_codes/config.php.
Set use_cache to false for disable using of system cache (L2).
Set use_local_cache to false for disable using of local cache (L1).