{"id":13545516,"url":"https://github.com/io238/laravel-iso-countries","last_synced_at":"2026-02-17T06:18:33.096Z","repository":{"id":47403308,"uuid":"325040883","full_name":"io238/laravel-iso-countries","owner":"io238","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.","archived":false,"fork":false,"pushed_at":"2024-03-14T21:56:03.000Z","size":518,"stargazers_count":43,"open_issues_count":6,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-13T14:34:08.430Z","etag":null,"topics":["cast","codes","countries","country-codes","currency","custom-casts","eloquent","iso","iso3166","iso4217","iso639-1","languages","laravel","php","world"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/io238.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-28T14:58:48.000Z","updated_at":"2025-08-13T07:03:43.000Z","dependencies_parsed_at":"2023-12-15T21:17:54.239Z","dependency_job_id":"a342a395-5b63-4718-9dd4-84754d7e3db7","html_url":"https://github.com/io238/laravel-iso-countries","commit_stats":{"total_commits":96,"total_committers":2,"mean_commits":48.0,"dds":0.04166666666666663,"last_synced_commit":"72e2d5f8077adb00bf0883a031a8df3b7116c684"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/io238/laravel-iso-countries","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io238%2Flaravel-iso-countries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io238%2Flaravel-iso-countries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io238%2Flaravel-iso-countries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io238%2Flaravel-iso-countries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/io238","download_url":"https://codeload.github.com/io238/laravel-iso-countries/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io238%2Flaravel-iso-countries/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29535934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T05:00:25.817Z","status":"ssl_error","status_checked_at":"2026-02-17T04:57:16.126Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cast","codes","countries","country-codes","currency","custom-casts","eloquent","iso","iso3166","iso4217","iso639-1","languages","laravel","php","world"],"created_at":"2024-08-01T11:01:04.687Z","updated_at":"2026-02-17T06:18:33.057Z","avatar_url":"https://github.com/io238.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Laravel ISO Countries\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/io238/laravel-iso-countries.svg?label=Version)](https://packagist.org/packages/io238/laravel-iso-countries)\n[![GitHub Tests Action Status](https://github.com/io238/laravel-iso-countries/workflows/Tests/badge.svg?branch=main)](https://github.com/io238/laravel-iso-countries/actions?query=workflow%3ATests+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/io238/laravel-iso-countries.svg?label=Downloads)](https://packagist.org/packages/io238/laravel-iso-countries)\n\nThis package provides ready-to-use application models and seeds the database with ISO data from various sources. This\npackage can be used in multi-language apps and supports Country/Language/Currency names in almost any locale.\n\n### Included datasets\n\n- [Countries: ISO 3166 alpha 2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) (incl. names, capital, lat/lon\n  coordinates, TLD, phone calling code, regions, population, gini, area)\n- [Languages: ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) (incl. names, language-family, wiki link)\n- [Currencies: ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) (incl. names, symbol, decimal digits, rounding)\n\nUnlike other packages, this one also includes relevant data relationships, such as:\n\n```php\n// Official languages spoken in Luxembourg ('LU')\nCountry::find('LU')-\u003elanguages;\n\n// Currencies used in Ghana ('GH')\nCountry::find('GH')-\u003ecurrencies;\n\n// Countries that have Spanish ('es') as one of their official languages \nLanguage::find('es')-\u003ecountries;\n\n// Countries that use the Euro ('EUR') as currency\nCurrency::find('EUR')-\u003ecountries;\n```\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require io238/laravel-iso-countries\n```\n\nThe latest version of this package requires PHP version 8.0 or above. If you need support for PHP 7.4, please install\nversion 2 of this package.\n\n### Migrations\n\nThere is no need to run any migrations. All country data information is stored in a pre-compiled SQLITE database that is\nstored within this package.\n\nBy default, this database includes all country/language/\u0026currency names translated into English, German, French, and\nSpanish. If you want to compile your own database with other languages,\nplease [see the instructions here](#data-updates--translations).\n\n### Rebuilding the database\n\nCountry-level ISO data does not change very often. Nevertheless, if at any time you want to update the ISO data to the\nlatest available version, you can manually re-seed the tables:\n\n### Config\n\nOptionally, you can publish the config file with:\n\n```bash\nphp artisan vendor:publish --provider=\"Io238\\ISOCountries\\ISOCountriesServiceProvider\" --tag=\"config\"\n```\n\nIn the config you can define, which translations of country/language/currency names you want to store in your DB.\n\nThis is the contents of the published config file:\n\n```php\n[\n    // Supported locales for names (countries, languages, currencies)\n    'locales' =\u003e [\n        'en',\n        'de',\n        'fr',\n        'es',\n    ],\n\n    // Path for storing your own SQLITE database\n    'database_path' =\u003e database_path('iso-countries.sqlite'),\n];\n```\n\nAfter making changes to the config you need to re-build the database with the following command:\n\n```bash\nphp artisan db:seed countries:build\n```\n\nThis will create a new SQLITE database and stores it in your project at `database/iso-countries.sqlite`. Exclude this\nfile from `.gitignore` to have it available in all environments.\n\n```gitignore\n# database/.gitignore\n\n*.sqlite*\n!iso-countries.sqlite\n```\n\n## Usage\n\n### Country model\n\n```php\nCountry::find('AD');\n\nIo238\\ISOCountries\\Models\\Country {\n     id: \"AD\",\n     alpha3: \"AND\",\n     name: \"{\"en\":\"Andorra\",\"de\":\"Andorra\",\"fr\":\"Andorre\",\"es\":\"Andorra\"}\",\n     native_name: \"Andorra\",\n     capital: \"Andorra la Vella\",\n     top_level_domain: \".ad\",\n     calling_code: \"376\",\n     region: \"Europe\",\n     subregion: \"Southern Europe\",\n     population: 78014,\n     lat: 42.5,\n     lon: 1.5,\n     demonym: \"Andorran\",\n     area: 468,\n   }\n```\n\n### Language model\n\n```php\nCountry::find('pt');\n\nIo238\\ISOCountries\\Models\\Language {\n     id: \"pt\",\n     iso639_2: \"por\",\n     iso639_2b: null,\n     name: \"{\"en\":\"Portuguese\",\"de\":\"Portugiesisch\",\"fr\":\"portugais\",\"es\":\"portugu\\u00e9s\"}\",\n     native_name: \"Português\",\n     family: \"Indo-European\",\n     wiki_url: \"https://en.wikipedia.org/wiki/Portuguese_language\",\n   }\n```\n\n### Currency model\n\n```php\nCurrency::find('COP');\n\nIo238\\ISOCountries\\Models\\Currency {\n     id: \"COP\",\n     name: \"{\"en\":\"Colombian Peso\",\"de\":\"Kolumbianischer Peso\",\"fr\":\"peso colombien\",\"es\":\"peso colombiano\"}\",\n     name_plural: \"Colombian pesos\",\n     symbol: \"CO$\",\n     symbol_native: \"$\",\n     decimal_digits: 0,\n     rounding: 0,\n   }\n```\n\n### Query relationships\n\nAll models have pre-defined many-to-many relationships that can be queried:\n\n```php\n// Retrieve languages that are spoken in Luxembourg\nCountry::find('LU')-\u003elanguages;\n\nIlluminate\\Database\\Eloquent\\Collection {                                                                  \n     all: [                                                                                                        \n       Io238\\ISOCountries\\Models\\Language {                                                                   \n         id: \"de\",                                                                                                 \n         iso639_2: \"deu\",                                                                                          \n         iso639_2b: \"ger\",                                                                                         \n         name: \"{\"en\":\"German\",\"de\":\"Deutsch\",\"fr\":\"allemand\",\"es\":\"alem\\u00e1n\"}\",                                \n         native_name: \"Deutsch\",                                                                                   \n         family: \"Indo-European\",                                                                                  \n         wiki_url: \"https://en.wikipedia.org/wiki/German_language\",                                                \n       },                                                                                                          \n       Io238\\ISOCountries\\Models\\Language {                                                                   \n         id: \"fr\",                                                                                                 \n         iso639_2: \"fra\",                                                                                          \n         iso639_2b: \"fre\",                                                                                         \n         name: \"{\"en\":\"French\",\"de\":\"Franz\\u00f6sisch\",\"fr\":\"fran\\u00e7ais\",\"es\":\"franc\\u00e9s\"}\",                 \n         native_name: \"français, langue française\",                                                                \n         family: \"Indo-European\",                                                                                  \n         wiki_url: \"https://en.wikipedia.org/wiki/French_language\",                                                \n       },                                                                                                          \n       Io238\\ISOCountries\\Models\\Language {                                                                   \n         id: \"lb\",                                                                                                 \n         iso639_2: \"ltz\",                                                                                          \n         iso639_2b: null,                                                                                          \n         name: \"{\"en\":\"Luxembourgish\",\"de\":\"Luxemburgisch\",\"fr\":\"luxembourgeois\",\"es\":\"luxemburgu\\u00e9s\"}\",       \n         native_name: \"Lëtzebuergesch\",                                                                            \n         family: \"Indo-European\",                                                                                  \n         wiki_url: \"https://en.wikipedia.org/wiki/Luxembourgish_language\",                                         \n       },                                                                                                          \n     ],                                                                                                            \n   }                                                                                                                                                                                                     \n```\n\n```php\n// Retrieve all countries that use the Euro (EUR) as currency.\nCurrency::find('EUR')-\u003ecountries-\u003epluck('name');\n\nIlluminate\\Support\\Collection {\n     all: [\n       \"Andorra\",\n       \"Austria\",\n       \"Åland Islands\",\n       \"Belgium\",\n       \"St. Barthélemy\",\n       \"Cyprus\",\n       \"Germany\",\n       \"Estonia\",\n       \"Spain\",\n       \"Finland\",\n       \"France\",\n       \"French Guiana\",\n       \"Guadeloupe\",\n       \"Greece\",\n       \"Ireland\",\n       \"Italy\",\n       \"Lithuania\",\n       \"Luxembourg\",\n       \"Latvia\",\n       \"Monaco\",\n       \"Montenegro\",\n       \"St. Martin\",\n       \"Martinique\",\n       \"Malta\",\n       \"Netherlands\",\n       \"St. Pierre \u0026 Miquelon\",\n       \"Portugal\",\n       \"Réunion\",\n       \"Slovenia\",\n       \"Slovakia\",\n       \"San Marino\",\n       \"French Southern Territories\",\n       \"Vatican City\",\n       \"Republic of Kosovo\",\n       \"Mayotte\",\n       \"Zimbabwe\",\n     ],\n   }\n```\n\n### Localized names\n\nEach of the package models (Country, Language, Currency) has a `-\u003ename` attribute, which will be displayed in the app's\nlocale, using the [spatie/laravel-translatable](https://github.com/spatie/laravel-translatable) package. The default\nconfig will migrate localized names for `en`, `de`, `fr`, and `es`. This can be adjusted in the [config](#config). The\nconfig `app.locale` and `app.fallback_locale` are automatically included.\n\n```php\n// Set the app locale\napp()-\u003esetLocale('fr');\n\n// Retrieve the top 10 countries in Africa (by population):\nIo238\\ISOCountries\\Models\\Country::where('region', 'Africa')-\u003eorderByDesc('population')-\u003elimit(10)-\u003epluck('name');\n\n// Country names will be returned according to the app locale (fr = French)\nIlluminate\\Support\\Collection {\n     all: [\n       \"Nigéria\",\n       \"Éthiopie\",\n       \"Égypte\",\n       \"Congo-Kinshasa\",\n       \"Afrique du Sud\",\n       \"Tanzanie\",\n       \"Kenya\",\n       \"Algérie\",\n       \"Soudan\",\n       \"Ouganda\",\n     ],\n   }\n```\n\n### Attribute casting\n\nIf you already use ISO codes in your models, you can enrich them by casting them as Country/Language/Currency model:\n\n```php\nuse Io238\\ISOCountries\\Casts\\Currency;\n\nclass MyModel{\n    \n    // ...\n\n    protected $casts = [\n        'currency' =\u003e Currency::class,\n    ];\n    \n    // ...\n}\n\n// Now you can dynamically retrieve all meta data associated with the currency\nMyModel::first()-\u003ecurrency;\n\nIo238\\ISOCountries\\Models\\Currency {\n     id: \"JPY\",\n     name: \"{\"en\":\"Japanese Yen\",\"de\":\"Japanischer Yen\",\"fr\":\"yen japonais\",\"es\":\"yen\"}\",\n     name_plural: \"Japanese yen\",\n     symbol: \"¥\",\n     symbol_native: \"￥\",\n     decimal_digits: 0,\n     rounding: 0,\n   }\n\n\n// When filling the model, the ISO code (string) or the model can be used \nMyModel::first()-\u003eupdate(['currency' =\u003e 'USD']);\nMyModel::first()-\u003eupdate(['currency' =\u003e Io238\\ISOCountries\\Models\\Currency::find('USD')]);\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [io238](https://github.com/io238)\n- [azakhozhiy](https://github.com/azakhozhiy)\n- https://restcountries.com\n- https://github.com/umpirsky/country-list\n- https://github.com/umpirsky/language-list\n- https://github.com/umpirsky/currency-list\n- https://github.com/spatie/laravel-translatable\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fio238%2Flaravel-iso-countries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fio238%2Flaravel-iso-countries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fio238%2Flaravel-iso-countries/lists"}