Download the PHP package universal-packages/country-service without Composer
On this page you can find all versions of the php package universal-packages/country-service. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download universal-packages/country-service
More information about universal-packages/country-service
Files in universal-packages/country-service
Download universal-packages/country-service
More information about universal-packages/country-service
Files in universal-packages/country-service
Vendor universal-packages
Package country-service
Short Description PHP 8.1+ 国家/省份查询库,数据源自 Shopify Country Service
License MIT
Package country-service
Short Description PHP 8.1+ 国家/省份查询库,数据源自 Shopify Country Service
License MIT
Please rate this library. Is it a good library?
Informations about the package country-service
Country Service
PHP 8.1+ 国家/省份查询库,数据源自 Shopify Country Service。
安装
通过 Packagist 安装:
用法
API 概览
| 方法 | 说明 |
|---|---|
getCountries(): Country[] |
返回当前 locale 的全部国家 |
getProvinces(string $countryCode): Province[] |
根据国家代码获取省份(大小写不敏感) |
getCountryByName(string $countryName): ?Country |
根据国家名精确匹配国家对象(大小写不敏感,自动 trim) |
resolve(string $input, bool $allowInvalidProvince = false): CountryResolveResult\|CountryProvinceResolveResult\|null |
解析国家代码或国家-省份代码(支持 UY-UY-AR 这类省份代码含连字符)。allowInvalidProvince 为 true 时,省份不存在会返回 CountryProvinceResolveResult(省份字段使用原始输入) |
性能说明
- 国家主数据按国家代码建立内存索引(
countryCode => Country)。 - 国家名查询使用惰性名称索引(
normalizedName => countryCode),首次调用时构建。 - 名称索引仅保存国家代码,查询时回查主索引,在保持查询速度的同时节省内存占用。
命令
| 命令 | 说明 |
|---|---|
composer fetch-countries |
拉取国家/省份数据 |
composer test |
运行测试 |
数据更新
GitHub Actions 每周一自动执行 fetch-countries,并提交变更。
许可证
MIT License
All versions of country-service with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
The package universal-packages/country-service contains the following files
Loading the files please wait ...