If you need Global Countries, States, and Cities In Laravel for forms, profiles, shipping, or search filters, this tutorial shows how to add the data in a quick and reliable manner. We are going to use a trusted package to bring a world database into your app without need of manual spreadsheets.
You can power country-state-city dropdowns, show Laravel timezones for scheduling, display Laravel currencies on product pages, and surface Laravel country codes for phone inputs or filters. Setup is fast and developer-friendly.
Install and set up the nnjeim/world package
The nnjeim/world brings a ready-to-use world database to your app, so you can add Global Countries, States, and Cities In Laravel without spreadsheets or manual seeding. It installs tables for countries, states, cities, timezones, currencies, and country codes, giving you clean data and fast queries. Use it to power checkout and profile forms with Laravel states by country and Cities by state Laravel.
We will install a world geo database into your Laravel app with countries, states, cities, timezones, currencies, and codes. Before moving forward you have a Laravel application up and running with database connection.
To install package, we will use composer. Open your terminal and enter below command:
composer require nnjeim/world
php artisan vendor:publish --provider="Nnjeim\World\WorldServiceProvider"
Once package is installed and configuration is publish, you need to run migrations.
php artisan migrate
Migrate command will generate database tables for storing global data for countries, states and cities into your own Laravel application. With help of this package’s methods you can access this data whenever required.
Currently there is no data into database. You need to run it’s command to download all the latest data from it’s repository and seed it into database. The package provides command just for that.
php artisan world:install
It will download latest data and seed it into your Laravel 12 application. For practice, we suggest add this into your own seeder for making it work across all the team members.
Examples: Global Countries, States, and Cities In Laravel 12
To understand this package’s functionality better let’s take a few examples to get different types of data like countries, cities and more.
List all countries
Suppose, you want to build country selection for user profile, where user selects own country for their profile. You need show all available countries to the user from where user can select. You can use below code snippet to get countries data while onbording.
use Nnjeim\World\World;
$countries = World::countries()->data;
List all states of a country in Laravel
For this on-boarding process, let’s see we want to take state selection based on user selected country then you can perform AJAX request to get state selection data.
use Nnjeim\World\World;
$states = World::states([
'filters' => [
'country_id' => $countryId,
],
])->data;
List all cities of a state
Populate city options based on the chosen state.
use Nnjeim\World\World;
$cities = World::cities([
'filters' => [
'state_id' => $stateId,
],
])->data;
It will get all cities for specific state containing it’s details.
List of all timezones
Allowing users to select their preferred timezone improves both user experience and notification accuracy. For example, if your app supports global bookings, proper timezone management ensures that users don’t accidentally book the same time slot across different regions.
use Nnjeim\World\World;
$timezones = World::timezones()->data;
Conclusion
With Laravel, you can easily add global countries, states, and cities data to your project and speed up development. The nnjeim/world package provides a ready-to-use world database with timezones, currencies, and country codes. Use it to create smooth forms, precise listings, and enhance the user experience with minimal effort.
If you are working with time-related data in your Filament Laravel application, you might need to Add Timezone Select to Filament Forms & Tables in Laravel. It explains how to seamlessly integrate timezone selection fields into your Filament forms and tables for a more localized and user-friendly experience.
