rinvex/countries
Framework-agnostic PHP country dataset and loader: access details for ~250 countries (name/native/official, ISO codes, demonym, capital, borders, area, currencies, languages, dialing codes, geo data, flags and emoji). Simple helpers like country('eg') and countries().
composer require rinvex/countries.php artisan vendor:publish --provider="Rinvex\Country\CountryServiceProvider".$egypt = country('eg');
echo $egypt->getName(); // "Egypt"
country() helper or Rinvex\Country\CountryLoader facade globally β it's autowired automatically via service provider.country($code) where $code is ISO 3166-1 alpha-2 (e.g., 'US', 'DE'), returning a Country DTO with rich methods.countries() to get an array of all countries, or CountryLoader::all() for full objects.CountryLoader::where('key.path', $values) for filtering:
$africanCountries = \Rinvex\Country\CountryLoader::where('geo.continent', ['AF' => 'Africa']);
$country->name, $country->capital, $country->emoji) via magic getters.getEmoji() for flag emojis (πͺπ¬)getFlag() to get SVG flag URLs or inline SVG (if assets are published).getTranslations()['fr']['common'] to localize display names.Select::make('Country')->options(
collect(countries())->pluck('name', 'iso_alpha2')
)
getCurrency() (single) or getCurrencies() (plural).getTimezones() or geo coordinates via getGeoJson().'US' not 'us'). Using lowercase may return null.countries() returns a trimmed dataset for performance; CountryLoader::all() loads full data.CountryLoader to add custom queries or override the JSON loader for external data sources (e.g., add custom fields).getAttributes() to inspect raw data, or getData() to see the full decoded JSON structure.countries() results in Redis or Memcached to avoid repeated JSON parsing.getTranslations() returns nested per-language names β use getNativeNames() to get all native names keyed by language code.resources/data/countries.json is static. To update (e.g., for new currencies or ISO changes), replace the file manually or write a custom loader.geo.continent uses codes like "AF" as keys β ensure your filters match exact keys (not values like "Africa").getCallingCodes() (plural) β returns an array, not just getCallingCode().How can I help you explore Laravel packages today?