Complete documentation for Laravel Worldable package.
- Installation - Install and configure the package
- Basic Usage - Learn the fundamentals
- Commands - Complete Artisan commands reference
- Modular Installation - Install only what you need
- Groups - Context-aware relationships (billing/shipping, etc.)
- Meta Data - Store custom data on relationships
- Continents - 7 continents
- Subregions - 24 UN geoscheme regions
- Countries - 250 countries with ISO codes
- States - 5,000+ states/provinces
- Cities - 148,000+ cities with coordinates
- Currencies - 160+ currencies with symbols and formatting
- Languages - 7,000+ languages with ISO codes
- Timezones - 100+ timezones with GMT offsets
- API Reference - Complete API documentation
- Validation Rules - Input validation rules
- Scopes - Query scopes reference
1. Direct Models (Traditional)
// Add foreign key to your migration
$table->foreignId('country_id')->nullable()->constrained('world_countries');
// Use standard relationship
class User extends Model {
public function country() {
return $this->belongsTo(Country::class);
}
}2. Polymorphic Relationships (Zero-Migration)
use Ritechoice23\Worldable\Traits\Worldable;
class User extends Model {
use Worldable;
}
$user->attachCountry('Nigeria');
$user->attachCity('Lagos', 'billing');| Feature | Description |
|---|---|
| 8 World Entities | Continents, Subregions, Countries, States, Cities, Currencies, Languages, Timezones |
| Modular Install | Install only what you need, add more later |
| Two Usage Modes | Traditional foreign keys OR polymorphic relationships |
| Context Groups | Separate billing/shipping, citizenship/residence |
| Smart Resolution | Accepts IDs, names, ISO codes automatically |
| Query Scopes | whereFrom(), whereInCity(), wherePricedIn(), whereSpeaks() |
| Money Formatting | $product->formatMoney(100) → "$100.00" with locale support |
| Bulk Operations | $user->attachCountries(['NG', 'GH', 'KE']) |
| Custom Metadata | Store extra data: $user->attachCountry('NG', 'billing', ['tax_id' => '...']) |
| Health Checks | php artisan world:health --detailed monitors data integrity |
| Streaming Parser | Memory-efficient handling of 148k+ cities |
| Progress Indicators | Real-time progress bars during installation |
- Streaming JSON Parser: Cities, countries, and states use memory-efficient streaming
- Progress Bars: Real-time progress indicators during installation
- Download Progress: Shows file sizes and download status
- Memory Optimized: Handles 148k+ cities with minimal memory footprint
- Batch Inserts: Data inserted in chunks (500-1000 records per batch)
- Automatic Memory Management: Sets appropriate memory limits for large datasets
class Order extends Model {
use Worldable;
}
$order
->attachCountry('United States', 'billing')
->attachState('California', 'billing')
->attachCountry('Canada', 'shipping')
->attachCity('Toronto', 'shipping')
->attachCurrency('USD', 'display')
->attachCurrency('CAD', 'settlement');class User extends Model {
use Worldable;
}
$user
->attachCountry('Nigeria', 'citizenship')
->attachCountry('United States', 'residence')
->attachCity('Lagos', 'birth_place')
->attachLanguages(['English', 'Yoruba'], 'fluent')
->attachTimezone('Africa/Lagos');class Product extends Model {
use Worldable;
}
$product->attachCurrency('USD');
$product->formatMoney(1000); // "$1,000.00"
// Multi-currency
$product->attachCurrencies(['USD', 'EUR', 'GBP']);# 1. Install package
composer require ritechoice23/laravel-worldable
# 2. Install world data
php artisan world:install --all
# 3. Check health
php artisan world:health
# 4. Link orphaned records (if any)
php artisan world:link
# 5. Verify
php artisan world:health --detailed# Already have countries, add states
php artisan world:install --states --with-dependencies# Check health
php artisan world:health --detailed
# Link orphaned records
php artisan world:link
# Verify
php artisan world:health# Remove specific component
php artisan world:uninstall --cities
# Remove everything
php artisan world:uninstall --all --force- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: daramolatunde23@gmail.com
The MIT License (MIT). See License File.