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?