nnjeim/world
Laravel package with a comprehensive dataset of countries, states, cities, timezones, currencies and languages, plus IP geolocation. Query via the World facade or built-in API routes, with installer command and optional custom DB connection.
Start by installing the package via Composer and running php artisan world:install (or manually publish config, run migrations, and seed with WorldSeeder). The package immediately provides country/state/city data and — since v1.1.38 — IP geolocation via World::geolocate(). Your first use case will likely be fetching a list of countries or populating a country/state/city dropdown in a registration form.
Use the World facade for most queries (e.g., World::countries(['filters' => ['iso2' => 'FR']])) for consistency and flexibility. For state/city selection, chain filters and fields: World::states(['filters' => ['country_id' => 77], 'fields' => 'cities']). Leverage the API routes (/api/{prefix}/countries, /api/states, etc.) to power AJAX-driven select boxes. Integrate World::geolocate() into registration or shipping flows: World::geolocate(['ip' => $ip]) returns linked Eloquent models, letting you pre-fill addresses. Use WorldHelper in services where dependency injection is preferred. Keep data fresh by scheduling php artisan world:geoip (once MaxMind license is configured) or periodically re-seeding via the seeder.
php artisan vendor:publish --tag=world --force after upgrading — config changes often add required options (e.g., GeoIP fallback toggles).ip-api.com fallback hits a 45 req/min limit and fails silently if exceeded. Prefer local GeoLite2 in production; set WORLD_GEOLOCATE_FALLBACK_API=false in .env to fail fast and debug.CF-Connecting-IP, X-Forwarded-For. In local development, explicitly pass ['ip' => '127.0.0.1'].world_countries, world_states, world_cities tables populated).fields=states,cities to eager-load relations in a single query. Avoid over-fetching: only request needed fields to reduce payload size.config/world.php — default behavior returns English names unless overridden.World::countries(['search' => 'France'])->cache(3600)) or use the API as a backend-only resource to avoid repeated DB lookups.How can I help you explore Laravel packages today?