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:
The latest version of this package requires PHP version 8.0 or above. If you need support for PHP 7.4, please install version 2 of this package.
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
- Martin
- 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
illuminate/database Version ^7.0|^8.40|^9.0|^10.0
illuminate/support Version ^7.0|^8.40|^9.0|^10.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