sokil/php-isocodes-db-i18n
Lightweight PHP library bundling ISO Codes database with i18n support. Look up ISO country, language, script and currency codes and get localized names via simple API. Useful for forms, dropdowns, validation and locale-aware apps.
Purpose Alignment: The package remains ideal for geopolitical data (ISO country/subdivision/language codes) with i18n support, but the 2025-12-02 database update (v4.19.0) introduces critical considerations:
Laravel Synergy: Unchanged. Still integrates with dependency injection, Eloquent, and Blade/Livewire.
Alternatives Comparison:
IsoCodes::getSubdivisions() → IsoCodes::getRegions()).iso3166-1_alpha2) are deprecated or renamed.| Risk Area | Mitigation Strategy | Update Impact (4.0.28) |
|---|---|---|
| Data Staleness | Schedule composer update or GitHub Actions workflow. |
HIGH: New database version (v4.19.0) may introduce deprecated codes or new fields. Requires validation of existing country_code values in production. |
| Breaking Changes | Test with phpunit for deprecated methods/classes. |
MEDIUM: Minor version bump suggests low risk, but database schema changes could affect serialization/deserialization. |
| Localization Gaps | Fallback to English or custom mappings. | LOW: Unlikely, but verify if new languages/subdivisions are missing translations. |
| Memory Usage | Load subsets (e.g., only countries). |
LOW: Unchanged. |
| Testing Coverage | Write tests for edge cases (e.g., invalid ISO codes). | HIGH: Add tests for new ISO codes and deprecated codes to catch regressions. |
CS for Serbia-Montenegro)?UK → GB) still needed? May conflict with new ISO standards.composer.json use ^4.0 (risk of auto-updates) or 4.0.28 (stable)?country_code values against the new dataset?require sokil/php-isocodes-db-i18n:^4.0 (or pinned to 4.0.28).country_code columns for deprecated/renamed values.composer require sokil/php-isocodes-db-i18n:4.0.28 # Pinned to avoid auto-updates
// config/app.php
'providers' => [
Sokil\IsoCodes\IsoCodesServiceProvider::class, // Verify class exists
],
php artisan vendor:publish --provider="Sokil\IsoCodes\IsoCodesServiceProvider"
deprecated_codes_fallback).use Sokil\IsoCodes\Facades\IsoCodes;
// Test new methods (if any)
$newSubdivision = IsoCodes::getSubdivisions('US'); // Check for new US states/territories
$deprecatedFallback = IsoCodes::getCountryName('CS'); // Should return Serbia or Montenegro?
country_code validation).// app/Console/Commands/ValidateIsocodes.php
public function handle() {
$invalidCodes = DB::table('users')
->whereNotIn('country_code', IsoCodes::getAllCountryCodes())
->get();
// Log or fix invalid codes
}
composer.json and test facade methods.4.0.28 in composer.json to avoid auto-updates until testing is complete.CS → RS or ME).country_code values in the database against the new dataset.deprecated_codes_fallback in the package config to handle legacy data gracefully.IsoCodes::getAllCountries(); // Check for new/removed entries
IsoCodes::getSubdivisions('FR'); // Test new French regions (e.g., Réunion)
| Scenario | Impact | Mitigation (Updated) |
|---|---|---|
| Deprecated ISO Codes | App crashes or shows stale |
How can I help you explore Laravel packages today?