rovereto/country
Composer 安装命令:
composer require rovereto/country
包简介
Laravel Country
README 文档
README
Several methods for searching timezones, continent by country code and subdivision code by subdivision name in IP2Location.
Installation
Install the package via composer:
composer require rovereto/country
Usage
- Determining the time zone for the country and subdivision
It takes as parameters the code of the country and subdivision according to the ISO-3166 standard.
use Rovereto\Country\Concerns\TimeZone; class MyClass { use TimeZone; ... } $myClass = new MyClass(); //find time zone for Trentino-Alto Adige, Italy //return "Europe/Rome" $myClass->getTimeZone("IT", "IT-32"); //or $myClass->getTimeZone("IT");
If there are several time zones in the country, when passing only the country code, returns the capital time zone.
use Rovereto\Country\Concerns\TimeZone; class MyClass { use TimeZone; ... } $myClass = new MyClass(); //find time zone for Canada $myClass->getTimeZone("CA"); //return "America/Toronto"
- Determining the continent by country code
It takes as parameters the code of the country according to the ISO-3166 standard.
use Rovereto\Country\Concerns\Continent; class MyClass { use Continent; ... } $myClass = new MyClass(); //find continent for Italy $myClass->getContinentByCountry("IT"); //return "Europe" //find continent code for Italy $myClass->getContinentCodeByCountry("IT"); //return "EU" //find continent by continent code $myClass->getContinentByCode("SA"); //return "South America"
But not all countries are on the same continent (part of the world). Russia is located in Europe and Asia. The second optional parameter with the subdivision code will allow you to define the continent for the Russian subdivision. Without a parameter, "EU" will be returned. Example:
use Rovereto\Country\Concerns\Continent; class MyClass { use Continent; ... } $myClass = new MyClass(); //find continent for Russia $myClass->getContinentCodeByCountry("RU"); //return "EU" //find continent for Moscow, Russia $myClass->getContinentByCountry("RU", "RU-MOW"); //return "Europe" //find continent for Novosibirskaya oblast', Russia $myClass->getContinentByCountry("RU", "RU-NVS"); //return "Asia" //find continent code for Moscow, Russia $myClass->getContinentCodeByCountry("RU", "RU-MOW"); //return "EU" //find continent code for Novosibirskaya oblast', Russia $myClass->getContinentCodeByCountry("RU", "RU-NVS"); //return "AS"
- Map Ip2Location a subdivision name onto the code of the subdivision
Free IP geolocation database "IP2Location™ LITE" does not return ISO-3166 subdivision code. The method getSubdivisionCode finds the code subdivision by country code and subdivision name in IP2Location.
use Rovereto\Country\Concerns\Subdivision; class MyClass { use Subdivision; ... } $myClass = new MyClass(); //find subdivision code for Trentino-Alto Adige, Italy $myClass->getSubdivisionCode("IT", "Trentino-Alto Adige"); //return "IT-32"
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use Semantic Versioning for versioning. For the versions available, see the tags on this repository.
Changelog
Refer to the Changelog for a full history of the project.
Support
The following support channels are available at your fingertips:
Author
- Alexander Ilyutkin Ilyutkin
See also the list of contributors who participated in this project.
License
This project is licensed under the The MIT License (MIT) Massachusetts Institute of Technology License - see the LICENSE.md file for details
rovereto/country 适用场景与选型建议
rovereto/country 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「timezone」 「country」 「continent」 「ip2location」 「subdivision」 「ISO_3166」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rovereto/country 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rovereto/country 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rovereto/country 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP class to get array of countries names with ISO_3166-1 alpha-2, alpha-3, numeric codes, ISD codes and continent
Continents & countries: ISO 3166-1 alpha-2 code, name, ISO 639-1 languages, capital, ISO 4217 currencies (symbols & numeric codes), native name, phone. JSON, CSV and SQL.
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
Datetime helpers for timezone handling
GeoLocation package for Laravel.
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-01