lykegenes/laravel-countries
Composer 安装命令:
composer require lykegenes/laravel-countries
包简介
Get informations about countries.
关键字:
README 文档
README
This package gives you access effortlessly to data from every country.
Install
Via Composer
composer require lykegenes/laravel-countries
Usage
You can search for a specific country using one of the following unique country codes :
$country = \Countries::getByAlpha2Code('CA'); // 2-letters country code from ISO3166 $country = \Countries::getByAlpha3Code('CAN'); // 3-letters country code from ISO3166 $country = \Countries::getByNumericCode(124); // 3-digits country code from ISO3166
You can retrieve an array of countries using their region of one of their currencies :
$countries = \Countries::getByCurrency('CAD'); /// A 3-letters currency code // Search by region $countries = \Countries::getByRegion(\Countries::$REGION_AFRICA); $countries = \Countries::getByRegion(\Countries::$REGION_AMERICAS); $countries = \Countries::getByRegion(\Countries::$REGION_ANTARCTICA); $countries = \Countries::getByRegion(\Countries::$REGION_ASIA); $countries = \Countries::getByRegion(\Countries::$REGION_EUROPE); $countries = \Countries::getByRegion(\Countries::$REGION_OCEANIA);
Results will be returned as Country objects. These objects have the following helper methods :
$country = \Countries::getByAlpha3Code('CAN'); $country->getAlpha2Code(); // 'CA' $country->getAlpha3Code(); // 'CAN' $country->getNumericCode(); // 124 $country->getOfficialName(); // 'Canada' $country->getAttributes(); // An array of all the raw attributes.
It is also possible to generate simple PHP array that can be used to generate an HTML select input.
// All parameters are optionnal. These are the defaults. // $key The country attribute to use as key. (default: 'cca3', 3-letters country code from ISO3166) // $official True for the offical country name, False for the common name. (default: false) // $localization A 3-letter locale code to try to translate. Will default to English if it`s missing. (default: null) $countries = \Countries::getListForDropdown('cca3', false, 'fra'); //This will return the following [ 'CAN' => 'Canada', 'USA' => 'États-Unis', ... ]
Credits
- Patrick Samson
- Mohammed Le Doze for compiling all this data in this repository.
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
lykegenes/laravel-countries 适用场景与选型建议
lykegenes/laravel-countries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26.52k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2016 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「countries」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lykegenes/laravel-countries 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lykegenes/laravel-countries 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lykegenes/laravel-countries 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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.
A package to delivery a wide seed array of Countries & their respective cities.
Geo module with countries and cities
A database with ISO country information in all configured translations
Class with a full list of all countries and corresponding states and regions
统计信息
- 总下载量: 26.52k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 18
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-21