lwwcas/laravel-countries
Eloquent-first country database for Laravel. Every ISO 3166 Alpha-2, Alpha-3 and numeric code, international phone code, currency, SVG and emoji flag, GeoJSON border and translation is a native Eloquent relationship—one Country:: call away, with no external API needed.
Laravel Countries is an Eloquent-first package that models the entire world as native Laravel relationships: ISO 3166 codes (Alpha-2, Alpha-3, numeric), international phone codes, currencies, national flags (SVG, emoji, HEX/RGB colors), GeoJSON borders, geographic coordinates, demographics, GDP, independence dates and region hierarchies — all translated into 9 languages and seeded straight into your own database.
No external APIs. No JSON files to fetch, parse and cache yourself. No stale array copy-pasted from a gist. Install the package, run one Artisan command, and countries behave like any other Eloquent model in your app — queryable, relatable, cacheable, testable.
⭐ Enjoying this package?
If Laravel Countries saved you some time, consider leaving a star on the repo. It's free, takes two seconds, and it's the main way other developers find this project.
Why Laravel Countries? • Features • Data Model • Available Languages • Getting Started • Usage • Testing • Contributing
Most "country list" packages for PHP give you a static array or a JSON file with a name and a two-letter code — fine for a dropdown, useless for anything real.
Laravel Countries is built for applications that actually do something with country data:
Country::whereIso('BR')->first() behaves like any other model — relationships, scopes, eager loading, caching, all included.country_id foreign key to users, addresses, orders — whatever your app needs — with a normal Eloquent relationship.Country:: behaves like any other Laravel model: scopes, relationships, eager loadingwhereIso, whereIsoAlpha3, whereIsoNumeric)wherePhoneCode)A quick look at what's on the Country model (full reference in the Method Listing docs):
| Category | Fields / capabilities |
|---|---|
| Identity | ISO Alpha-2, ISO Alpha-3, ISO numeric, slug, UID, official name |
| Geography | Latitude/longitude, GeoJSON borders, area (km²), bordering countries |
| Economy | Currency, GDP |
| Demography | Population |
| Communication | International phone code, top-level domain (TLD) |
| Identity/branding | Flag (SVG), flag emoji, flag colors (HEX/RGB) |
| History | Independence date |
| Classification | Region / continent, WMO code |
| Localization | Name and region translated in 9 languages |
Every country and region name is translated in all 9 languages below — the table shows how many countries have that language as an official/native language, not translation coverage (translation coverage is 100% across all languages).
You don't have to install all 9. Pick only the languages your app actually serves at install time, and add or remove languages later — Laravel Countries manages the translation rows for you, so your database only ever stores what you're using.
| Language | Flag | Country | Countries where it's an official language |
|---|---|---|---|
| Arabic | 🇸🇦 | Saudi Arabia | 25 |
| Dutch | 🇳🇱 | Netherlands | 3 |
| English | 🇬🇧 | United Kingdom | 67 |
| German | 🇩🇪 | Germany | 6 |
| Italian | 🇮🇹 | Italy | 4 |
| Portuguese | 🇧🇷 | Brazil | 9 |
| Russian | 🇷🇺 | Russia | 4 |
| Spanish | 🇪🇸 | Spain | 21 |
| Turkish | 🇹🇷 | Turkey | 2 |
Missing a language? Contributions are welcome — the guide explains how translations get reviewed.
Install via Composer:
composer require lwwcas/laravel-countries
Run the installer:
php artisan w-countries:install
That's it — the countries table is seeded and ready to query.
In production, use --force to skip confirmation prompts:
php artisan w-countries:install --force
If migrations already ran during deploy and you only need the data:
php artisan w-countries:seed --languages=en,pt,es
To list the equivalent manual db:seed commands:
php artisan w-countries:seed --show-commands
See the Seeders documentation for the full production guide and manual seeder class reference.
Only need Portuguese and English today? Only seed those two — there's no need to carry all 9 languages in your database if your app doesn't use them:
php artisan w-countries:seed --languages=en,pt
Adding a new market later (say, Spanish) doesn't mean starting over — install the new language on top of what you already have. The same applies in reverse: if a language is no longer needed, you can remove it without touching the rest of your country data.
Full add/remove workflow and command reference → Available Languages docs
Basic lookups:
use Lwwcas\LaravelCountries\Models\Country;
Country::whereIso('BR')->first();
Country::whereIsoAlpha3('BRA')->first();
Country::whereSlug('brasil')->first();
Flags — SVG, emoji, and colors:
$country = Country::whereIso('FR')->first();
$country->flag_svg; // SVG markup
$country->flag_emoji; // 🇫🇷
$country->flag_colors; // ['#0055A4', '#FFFFFF', '#EF4135']
Phone codes & currency:
Country::wherePhoneCode('+55')->first();
Country::whereGdp(1000)->get(); // GDP in billions USD
Geographic data — coordinates & GeoJSON:
$country = Country::whereIso('JP')->first();
$country->latitude;
$country->longitude;
$country->geojson; // ready to drop into any map library
Language & region:
Country::whereLanguage('en')->get();
Country::whereLanguages(['en', 'fr'])->get();
Looking for relationships, scopes, config, or translation helpers? → See the full documentation
composer test
Contributions, translations, and bug reports are very welcome. Please read CONTRIBUTING.md before opening a pull request.
The MIT License (MIT). Please see LICENSE.md for more information.
How can I help you explore Laravel packages today?