enadabuzaid/country-data
最新稳定版本:1.0.0
Composer 安装命令:
composer require enadabuzaid/country-data
包简介
Laravel package for country information (config-based, reusable, and localized)
README 文档
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:
arabgulfmuslim-majoritymiddle-eastasia,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-jsoncommand- Optional database support
📄 License
MIT — built by @enadabuzaid
统计信息
- 总下载量: 1.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-05