monarobase/country-list). Can be published as a config file (config/country-list.php) for easy customization (e.g., default language, excluded regions).countries), enabling SQL queries (e.g., Country::where('iso2', 'US')->first()).CountryService::getAll()) and sanitize inputs (e.g., validate ISO codes).Country::findByIso('US')).Cache::remember('countries', now()->addYear(), fn() => CountryList::all())).country_updates table.michiellis/laravel-flag if needed.Rule::in(['US', 'CA', ...])).Country model:
php artisan vendor:publish --provider="MonaroBase\CountryList\CountryListServiceProvider"
{
"data": {
"id": "US",
"name": "United States",
"name_es": "Estados Unidos",
"iso2": "US",
"iso3": "USA"
}
}
Country::getByIso('DE')->postalCodeFormat).composer require monarobase/country-list
php artisan vendor:publish --tag=country-list-config
php artisan migrate
CountryList::load()).use MonaroBase\CountryList\CountryList;
public function run()
{
$countries = CountryList::all();
foreach ($countries as $country) {
Country::create($country);
}
}
// app/Console/Commands/UpdateCountries.php
public function handle()
{
$newData = CountryList::fetchLatest();
Country::whereIn('iso2', array_keys($newData))->update($newData);
}
composer.json to avoid surprises:
"monarobase/country-list": "dev-maintenance"
countries table alongside migrations.null or default to English).Cache::forever() for static lists.iso2, iso3, and name columns.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Stale country data | Incorrect dropdowns, API errors | Quarterly manual updates + fallback API |
| Database corruption | Missing countries in UI | Regular backups + repair command |
| Cache invalidation issues | Stale data in frontend | Use Cache::tags('countries') |
| Localization gaps | Missing translations in UI | Supplement with Crowdin/Google Sheets |
| Package abandonment | No future updates | Fork and maintain internally |
CountryList methods and Eloquent queries.How can I help you explore Laravel packages today?