Download the PHP package io238/laravel-iso-countries without Composer
On this page you can find all versions of the php package io238/laravel-iso-countries. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download io238/laravel-iso-countries
More information about io238/laravel-iso-countries
Files in io238/laravel-iso-countries
Package laravel-iso-countries
Short Description Ready-to-use Laravel models and relations for country (ISO 3166), language (ISO 639-1), and currency (ISO 4217) information with multi-language support.
License MIT
Homepage https://github.com/io238/laravel-iso-countries
Informations about the package laravel-iso-countries
Laravel ISO Countries
This package provides ready-to-use application models and seeds the database with ISO data from various sources. This package can be used in multi-language apps and supports Country/Language/Currency names in almost any locale.
Included datasets
- Countries: ISO 3166 alpha 2 (incl. names, capital, lat/lon coordinates, TLD, phone calling code, regions, population, gini, area)
- Languages: ISO 639-1 (incl. names, language-family, wiki link)
- Currencies: ISO 4217 (incl. names, symbol, decimal digits, rounding)
Unlike other packages, this one also includes relevant data relationships, such as:
Installation
You can install the package via composer:
Version support
| Package version | Laravel versions | PHP versions |
|---|---|---|
1.4.x |
8 to 13 |
8.1+ |
1.3.x |
8 to 12 |
8.1+ |
1.2.x |
7 to 10 |
8.1+ |
1.1.3 |
7 to 9 |
7.4+ |
1.0.0 to 1.1.2 |
8 |
7.4+ |
0.2.x |
8 |
7.4+ |
Notes:
- The package's own minimum PHP version is shown above, but newer Laravel versions may require a higher PHP version.
- In practice that means Laravel
12requires PHP8.2+, and Laravel13requires PHP8.3+. - Older
1.2.xand1.1.xreleases include Laravel7in their composer constraints.1.3.xand later only verify Laravel8+in CI.
Migrations
There is no need to run any migrations. All country data information is stored in a pre-compiled SQLITE database that is stored within this package.
By default, this database includes all country/language/¤cy names translated into English, German, French, and Spanish. If you want to compile your own database with other languages, please see the instructions here.
Rebuilding the database
Country-level ISO data does not change very often. Nevertheless, if at any time you want to update the ISO data to the latest available version, you can manually re-seed the tables:
Config
Optionally, you can publish the config file with:
In the config you can define, which translations of country/language/currency names you want to store in your DB.
This is the contents of the published config file:
After making changes to the config you need to re-build the database with the following command:
This will create a new SQLITE database and stores it in your project at database/iso-countries.sqlite. Exclude this
file from .gitignore to have it available in all environments.
Usage
Country model
Language model
Currency model
Query relationships
All models have pre-defined many-to-many relationships that can be queried:
Localized names
Each of the package models (Country, Language, Currency) has a ->name attribute, which will be displayed in the app's
locale, using the spatie/laravel-translatable package. The default
config will migrate localized names for en, de, fr, and es. This can be adjusted in the config. The
config app.locale and app.fallback_locale are automatically included.
Attribute casting
If you already use ISO codes in your models, you can enrich them by casting them as Country/Language/Currency model:
Testing
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- io238
- azakhozhiy
- https://restcountries.com
- https://github.com/umpirsky/country-list
- https://github.com/umpirsky/language-list
- https://github.com/umpirsky/currency-list
- https://github.com/spatie/laravel-translatable
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-iso-countries with dependencies
illuminate/contracts Version ^7.0|^8.40|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^7.0|^8.40|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^7.0|^8.40|^9.0|^10.0|^11.0|^12.0|^13.0
spatie/laravel-translatable Version ^4.6|^5.0|^6.0
slowprog/composer-copy-file Version ^0.3
components/flag-icon-css Version ^3.5.0
umpirsky/country-list Version ^2.0.6
umpirsky/language-list Version ^v1.1
umpirsky/currency-list Version ^v1.1.1