brianfp/lumen-world
Composer 安装命令:
composer require brianfp/lumen-world
包简介
Provide countries, states, and cities models database.
README 文档
README
This package focused on World Countries, Regions, and Cities database with locale support for Lumen.
Conceptions
There are 5 main objects in this package.
- World: the earth world.
- Continent: 7 continent
- Country: 248 countries
- Division: Divisions such as state/province.
- City: the last level of region, some cities up to Country, some up to Division.
Attributes
Common attributes:
name: Common name of region(english).full_name: Full name or official name(english).code: ISO-3166-1-alpha2/ISO-3166-2 codelocal_name: translation of Common namelocal_full_name: translation of full namelocal_alias: alias in different languagelocal_abbr: Abbreviation
Country spec attributes:
emoji: Emoji flag of countrycapital: Captial of this countrycode_alpha3: Code of ISO-3166-1-alpha3currency_code: ISO-4177 Currency Code, e.g. USD, CNYcurrency_name: ISO-4177 Currency Name,local_currency_name: ISO-4177 Currency name in locale
Example:
use Khsing\World\World; $china = World::getByCode('cn'); $china->setLocale('zh-cn'); $china->name; // China $china->local_name; // 中国 $china->full_name; // People's Republic of China $china->local_full_name; // 中华人民共和国 $china->emoji; // 🇨🇳 $china->callingcode; // 86 $china->code; // CN $china->code_alpha3; // CHN $china->has_division; // true $china->currency_code; // CNY $china->currency_name; // Yuan Renminbi $china->local_currency_name; // 人民币
Localization
Right now, only English(default and fallback) and Chinese-Simp zh-cn are supported. Locale settings is following Lumen project settings in config/app.php.
Setup
composer require
composer require brianfp/lumen-world
Usage
- get all Continent
use Khsing\World\World; World::Continents()
- get all Countries
use Khsing\World\World; World::Countries()
- get country/city/division by code
use Khsing\World\World; World::getByCode('cn'); // iso-3166 alpha 2 code World::getByCode('chn'); // iso-3166 alpha 3 code World::getByCode('cn-11'); // Beijing
- get countries belong to a continent
use Khsing\World\Models\Continent; $asia = Continent::getByCode('AS'); $countries = $asia->countries()->get(); // or use children method $countries = $asia->children();
- get continent or parent
$china = Country::getByCode('cn'); $asia = $china->parent();
- get division/state/province via Conutry
$china = Country::getByCode('cn'); $provinces = $china->divisions()->get() // or use children method $provinces = $china->children();
- get cities via Country or Division.
$china = Country::getByCode('cn'); // check has_division to determine next level is division or city. $china->has_division; // true, otherwise is false $regsions = $china->children();
Contributions
If you want contribute to this library, issue and pr are welcome. please following those steps.
- start a new laravel project and install this library.
- install orangehill/iseed.
- modify datas via sql.
- generate seeds via
artisan iseed world_cities,world_cities_locale,world_continents,world_continents_locale,world_countries,world_countries_locale,world_divisions,world_divisions_locale - replace
delete()withtruncat(),cd database/seeds/ && sed -i 's/->delete()/->truncat()/g' World*.php - copy seeds files into library.
- commit your work. ;)
TODO
- change the way to seed data, eg. loading data from json?
- add front-end support
- find a way to update dataset
Thanks
About
This package published under MIT license. If you have any question or suggestion, please feel free to submit a issue, or email me Guixing<khsing.cn(AT)gmail.com>.
Have a nice day.
brianfp/lumen-world 适用场景与选型建议
brianfp/lumen-world 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.93k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「country」 「region」 「city」 「world」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 brianfp/lumen-world 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 brianfp/lumen-world 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 brianfp/lumen-world 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Miaoxing Region Plugin
Philippines region, province, cities/municipalities and barangays Laravel migration and table seeder.
Sun Country is the package that helps you to get the country name & dialing code by the country ISO 3166-1 Alpha-2 code.
List of all countries with names and ISO 3166-1 codes in all languages and data formats for Laravel
Country select field type.
List of Italian Regioni (Regions), Province (Provinces), and Comuni (Municipalities) with data from Istat
统计信息
- 总下载量: 4.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-09