enadabuzaid / country-data
Laravel package for country information (config-based, reusable, and localized)
Installs: 1 056
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/enadabuzaid/country-data
Requires
- php: ^8.2
- illuminate/support: ^11.0 || ^12.0
This package is auto-updated.
Last update: 2025-09-12 13:03:18 UTC
README
A clean and reusable Laravel package for accessing comprehensive country information โ including localized names, flags, dial codes, currencies, timezones, and more โ all stored in a config/countries.php
file for maximum performance.
๐ฏ๐ด Built with multilingual support, region filters, and helper methods โ ideal for dropdowns, admin panels, and international applications.
โ Features
- ๐ฆ Publishable country list as
config/countries.php
- ๐ Multilingual support (English and Arabic)
- ๐ Filters for Arab, Gulf, Muslim-majority, Continents, and more
- ๐ Dial codes with emoji flags and SVG URLs
- ๐ Search countries by name, code, or filter
- ๐งฉ Helper formatters for frontend select menus
- โก Laravel-native config access (uses
config()
andconfig:cache
)
๐ Installation
Add the package locally:
composer require enad/country-data
Publish the config file:
php artisan vendor:publish --tag=country-data
This will copy countries.php
into your Laravel app's config folder:
config('countries');
๐ Documentation
๐ Available Static Methods
use CountryData; // via Facade
Method | Description |
---|---|
getArabCountries() |
Returns all Arab countries |
getGulfCountries() |
Returns Gulf Cooperation Council countries |
getByFilter('muslim-majority') |
Returns countries by custom filter |
getByCode('SA') |
Gets full country data by code |
searchByName('Jordan') |
Finds country by name in English or Arabic |
getName('JO', 'ar') |
Returns the name of a country in a specific locale |
getFlag('JO') |
Returns the flag emoji |
getDialCodes(true) |
Returns list of dial codes, optionally with flags |
getSelectOptions('ar') |
Returns array for select dropdowns (label + value) |
๐ Example: Get Dial Codes with Flags
CountryData::getDialCodes(true);
Returns:
[ ['code' => 'JO', 'dial' => '+962', 'flag' => '๐ฏ๐ด', 'flag_url' => 'https://flagcdn.com/jo.svg'], ... ]
๐ Example: Get Arab Countries
CountryData::getArabCountries();
๐ Example: Search by Arabic Name
CountryData::searchByName('ุงูุณุนูุฏูุฉ', 'ar');
๐ Example: Select Options for Vue/React
CountryData::getSelectOptions('en'); // => [ ['label' => 'Jordan', 'value' => 'JO'], ... ]
๐ง Extensible Filters
Available filters
on countries include:
arab
gulf
muslim-majority
middle-east
asia
,africa
,europe
,north-america
, etc.
๐ File Structure
config/
โโโ countries.php # Published config data
src/
โโโ CountryData.php # All logic methods
โโโ Facades/CountryData.php
โโโ CountryDataServiceProvider.php
๐งช Coming Soon
getByContinent('Asia')
getSelectOptionsWithFlags()
country-data:export-json
command- Optional database support
๐ License
MIT โ built by @enadabuzaid