laravel-enso/countries
Composer 安装命令:
composer require laravel-enso/countries
包简介
Countries for Laravel Enso
README 文档
README
Description
Countries provides the country reference dataset used across the Laravel Enso ecosystem.
The package ships the countries table, a JSON-backed seeder for the full country list, an Eloquent model with a few convenience behaviors, and an authenticated options endpoint meant for select inputs.
It is a foundational backend package for address management, currencies, webshop flows, and any feature that needs normalized country metadata such as ISO codes, currency details, calling codes, or flags.
Installation
This package comes pre-installed in Laravel Enso applications that require country metadata.
For standalone installation in an Enso-based application:
composer require laravel-enso/countries
The package automatically:
- loads its API routes
- loads its migrations
- publishes its seeders when requested
Run the migrations after installation:
php artisan migrate
If you want the package seeder in your application's database seeders directory, publish it with:
php artisan vendor:publish --tag=countries-seeder
Then seed the table:
php artisan db:seed --class="LaravelEnso\Countries\Database\Seeders\CountrySeeder"
Features
- Creates the
countriestable with ISO, currency, region, and calling metadata. - Ships a JSON-backed seeder for the full country dataset.
- Provides an Eloquent
Countrymodel with rememberable lookup keys. - Exposes an authenticated
optionsendpoint for select inputs. - Returns only active countries through the options endpoint.
- Includes a region label helper that adapts for Romania and the United States.
Usage
Fetch active country options through the API:
route('core.countries.options');
Query the model directly:
use LaravelEnso\Countries\Models\Country; $romania = Country::whereIso31662('RO')->firstOrFail(); $label = $romania->regionLabel();
The options endpoint serializes countries in a frontend-friendly shape:
{
"id": 1,
"name": "Romania",
"currencyCode": "RON"
}
::: warning Note The package exposes only active countries through its options endpoint.
If you seed or modify the dataset manually, remember that inactive rows will not be returned by core.countries.options.
:::
API
Routes
All package routes are registered under:
- prefix:
api/core/countries - name prefix:
core.countries. - middleware:
api,auth,core
Endpoints:
GET /api/core/countries/options
Controller
LaravelEnso\Countries\Http\Controllers\Options
Behavior:
- builds select-style options through
LaravelEnso\Select\Traits\OptionsBuilder - filters by active countries only
- allows querying by
nameandiso_3166_3
Resource
LaravelEnso\Countries\Http\Resources\Country
Serialized attributes:
idnamecurrencyCode
Model
LaravelEnso\Countries\Models\Country
Useful traits:
ActiveStateAvoidsDeletionConflictsHasFactoryRememberable
Rememberable keys:
idiso_3166_2name
Useful method:
regionLabel(): string
Seeder
LaravelEnso\Countries\Database\Seeders\CountrySeeder
Reads the dataset from:
vendor/laravel-enso/countries/database/countries.json
Depends On
Required Enso packages:
laravel-enso/core↗laravel-enso/dynamic-methods↗laravel-enso/enums↗laravel-enso/helpers↗laravel-enso/migrator↗laravel-enso/rememberable↗laravel-enso/select↗
Framework dependency:
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!
laravel-enso/countries 适用场景与选型建议
laravel-enso/countries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39.86k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「manager」 「countries」 「enso」 「laravel-enso」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 laravel-enso/countries 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravel-enso/countries 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 laravel-enso/countries 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
List of all countries with names and ISO 3166-1 codes in all languages and data formats for Laravel
Laravel 5.2 package that provides basic geographical data like Countries, Regions and Cities.
account activation (double opt-in) for the laravel auth scaffold
A package to delivery a wide seed array of Countries & their respective cities.
KCFinder web file manager
统计信息
- 总下载量: 39.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-31