savannabits/countries
A Laravel package for adding country, state/region, and city data to your application, with models, migrations, seeders, and helpers for working with location records.
composer require savannabits/countriesphp artisan vendor:publish --provider="Savannabits\Countries\CountriesServiceProvider" (migrations + config). Confirm the config file (config/countries.php) before migrating.php artisan migrate and seed the package data. Seeding is the heavy step (cities in particular), so run it explicitly rather than as part of a normal db:seed deploy.Country, Region, City, Currency, Timezone under the Savannabits\Countries\Models namespace) and the package README for the install/seed artisan command for your version.First use case: populate a country dropdown and resolve a phone/ISO code.
use Savannabits\Countries\Models\Country;
$countries = Country::orderBy('name')->get(['id', 'name', 'iso_2', 'phone_code']);
// Blade: <option value="{{ $c->id }}" data-iso="{{ $c->iso_2 }}">{{ $c->name }}</option>
v1.0.0 adds Laravel 10 support; check your PHP version (Laravel 10 requires PHP 8.1+) and that your other dependencies allow it before upgrading.
Cache::remember('countries', ...)) and only bust the cache after re-seeding.Country -> regions -> cities. Always eager-load (Country::with('regions')) when rendering cascading address forms; otherwise you get an N+1 per country.country_id via an AJAX endpoint returning regions, and the city dropdown off region_id. Seed only the regions/cities you actually operate in if you don't need global coverage.exists:countries,iso_2) rather than display names; store the stable code and resolve the label at render time. Same for currency/timezone.Country model later without touching views/controllers.addresses table, with foreign keys where it's useful and plain iso_2 strings where you want to decouple from package tables.lang/ files rather than relying on the package's English names.migrate:fresh --seed only in local env.savannabits/countries explicitly and run composer why-not savannabits/countries 1.0.0 if the upgrade stalls.countries.php, update any raw queries and foreign keys in your own migrations.iso_2, iso_3, phone_code, and foreign keys (country_id, region_id) are indexed; lookups by code happen on every form render.DateTimeZone::listIdentifiers() exactly; validate before passing to Carbon/DateTimeZone.Country::count()) before chasing the code.How can I help you explore Laravel packages today?