aaix/laravel-countries
Composer 安装命令:
composer require aaix/laravel-countries
包简介
A modern Laravel country-data package: idempotent seeders, zero-touch install, no interactive commands. Opinionated fork of lwwcas/laravel-countries.
关键字:
README 文档
README
Laravel Countries
A modern Laravel country-data package — idempotent seeders, zero-touch install, ergonomic API.
Opinionated fork of lwwcas/laravel-countries.
Install
composer require aaix/laravel-countries php artisan migrate
Migrations load automatically via the package service provider.
Seed
php artisan db:seed --class="Aaix\\LaravelCountries\\Database\\Seeders\\DatabaseSeeder"
Seeds 5 regions, 245 countries, 9 language translations and the native_name column. Idempotent — safe to re-run. See Seeding for deploy-pipeline integration.
Principle
A country-data package should do exactly two things: create the tables and keep the rows in sync. Three commands (composer require, php artisan migrate, php artisan db:seed) do both. The seeders are idempotent, so running them on every deploy keeps rows in sync with no extra wiring.
Migrating from lwwcas/laravel-countries
Same 7-table schema, same Eloquent models, same query scopes, same country data. Migration is mostly a namespace swap — see the step-by-step guide in the docs:
Usage
use Aaix\LaravelCountries\Models\Country; // Lookup $de = Country::getByCode('DE'); // alpha-2, case-insensitive $de = Country::whereIsoAlpha3('DEU')->first(); $de = Country::whereIso('276')->first(); // matches alpha-2, alpha-3, or numeric // Names $de->name; // current app locale, falls back to config fallback $de->nameInLang('ja'); // "Germany" (falls back if 'ja' missing) $de->official_name; // "Federal Republic of Germany" $de->native_name; // "Deutschland" // Bulk localized list — ready for dropdowns Country::listInLang('de'); // Collection(['DE' => 'Deutschland', 'FR' => 'Frankreich', ...] sorted by name) // Flag $de->getFlagEmoji(); // 🇩🇪 $de->flag_colors_hex; // ['#000000', '#DD0000', '#FFCE00'] // Relations $de->region; // CountryRegion $de->coordinates; // CountryCoordinates $de->extras; // CountryExtras (religions, orgs, sports, internet stats) $de->geographical; // CountryGeographical (GeoJSON)
Available query scopes: whereIso, whereIsoAlpha2, whereIsoAlpha3, whereIsoNumeric, whereCurrency, whereBorders, whereDomain, whereLanguages, whereFlagColors, wherePhoneCode, whereIndependenceDay, whereStatistics, whereName, whereSlug, whereWmo.
Table layout
| Table | Purpose |
|---|---|
lc_regions |
5 continents (Africa, Americas, Asia, Europe, Oceania) |
lc_region_translations |
Region names per locale |
lc_countries |
245 countries — ISO codes, capital, currency, flag metadata, native_name, population, GDP etc. |
lc_countries_translations |
Country name + slug per locale |
lc_countries_coordinates |
Latitude/longitude and formatted coordinate variants |
lc_countries_geographical |
Country outline as GeoJSON |
lc_countries_extras |
Religions, international orgs, national sport, internet stats, cybersecurity agency |
Translations are handled by astrotomic/laravel-translatable (already a dependency). The withTranslation() global scope eager-loads the current locale + fallback locale — so Country::all()->pluck('name') is one query, not N+1.
Requirements
- PHP 8.2+
- Laravel 11+
Testing
composer test
Credits
- Lucas Duarte — original package author, country-data curator
- Jonas Gnioui — fork maintainer
License
MIT. See LICENSE.md.
aaix/laravel-countries 适用场景与选型建议
aaix/laravel-countries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 71 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「geolocation」 「geography」 「laravel」 「countries」 「ISO codes」 「coordinates」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aaix/laravel-countries 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aaix/laravel-countries 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aaix/laravel-countries 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
The official PHP library for apiip.net that allowing customers to automate IP address validation and geolocation lookup in websites, applications and back-office system. Visit our API docs at https://apiip.net/documentation
PHP FFI bindings for Uber's H3 hexagonal hierarchical geospatial indexing system
Geo-Toolkit for PHP
Supports GeoIP services (sypexgeo.net).
Doctrine2 simple support for spatial types and functions
统计信息
- 总下载量: 71
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 43
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-24