rinvex / country
Rinvex Country是一个简单轻量级的包,可以灵活地检索国家详情。它包含了包括名称、通称、首都、ISO代码、区号、地理数据、货币、国旗、emoji以及其他所有250个国家的属性,一应俱全。
Requires
- php: ^7.1.3
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.20.0
- phpunit/phpunit: ^7.0.0
This package is auto-updated.
Last update: 2022-02-01 13:00:46 UTC
README
Rinvex Country是一个简单轻量级的包,可以灵活地检索国家详情。它包含了包括名称、通称、首都、ISO代码、区号、地理数据、货币、国旗、emoji以及其他所有250个国家的属性,一应俱全。
⚠️ 此包已被重命名,现在在rinvex/countries维护,作者建议使用新包。
使用方法
使用composer require rinvex/country
安装,然后直观使用
// Get single country $egypt = country('eg'); // Get country name // Get country native name echo $egypt->getName(); echo $egypt->getNativeName(); // Get country official name // Get country ISO 3166-1 alpha2 code echo $egypt->getOfficialName(); echo $egypt->getIsoAlpha2(); // Get country area // Get country borders echo $egypt->getArea(); echo $egypt->getBorders(); // Get country currencies // Get country languages echo $egypt->getCurrencies(); echo $egypt->getLanguages(); // Get country emoji // Get country flag echo $egypt->getEmoji(); echo $egypt->getFlag(); // Get all countries // Get countries with where condition (continent: Oceania) $countries = countries(); $whereCountries = \Rinvex\Country\CountryLoader::where('geo.continent', ['OC' => 'Oceania']);
注意:此包是框架无关的,因此它兼容任何PHP框架,没有任何依赖,除了PHP版本本身^7.0。太棒了,对吧?😃
目录
高级使用
获取国家属性(自描述性)
$egypt = country('eg'); // Egypt // مصر $egypt->getName(); $egypt->getNativeName(); // Arab Republic of Egypt // جمهورية مصر العربية $egypt->getOfficialName(); $egypt->getNativeOfficialName(); // Egyptian // Cairo $egypt->getDemonym(); $egypt->getCapital(); // EG // EGY $egypt->getIsoAlpha2(); $egypt->getIsoAlpha3(); // 818 // .eg $egypt->getIsoNumeric(); $egypt->getTld(); // [".eg",".مصر"] // ["EG","Arab Republic of Egypt"] $egypt->getTlds(); $egypt->getAltSpellings(); // Arabic // {"ara":"Arabic"} $egypt->getLanguage(); $egypt->getLanguages(); // Africa // true $egypt->getContinent(); $egypt->usesPostalCode(); // 27 00 N // 30 00 E $egypt->getLatitude(); $egypt->getLongitude(); // 26.756103515625 // 29.86229705810547 $egypt->getLatitudeDesc(); $egypt->getLongitudeDesc(); // 31.916667 // 36.333333 $egypt->getMaxLatitude(); $egypt->getMaxLongitude(); // 20.383333 // 24.7 $egypt->getMinLatitude(); $egypt->getMinLongitude(); // 1002450 // Africa $egypt->getArea(); $egypt->getRegion(); // Northern Africa // EMEA $egypt->getSubregion(); $egypt->getWorldRegion(); // 002 // 015 $egypt->getRegionCode(); $egypt->getSubregionCode(); // false // ["ISR","LBY","SDN"] $egypt->isLandlocked(); $egypt->getBorders(); // Yes // 20 $egypt->isIndependent(); $egypt->getCallingCode(); // ["20"] // 0 $egypt->getCallingCodes(); $egypt->getNationalPrefix(); // 9 // [9] $egypt->getNationalNumberLength(); $egypt->getNationalNumberLengths(); // 2 // [2] $egypt->getNationalDestinationCodeLength(); $egypt->getnationaldestinationcodelengths(); // "00" // {{recipient}}\n{{street}}\n{{postalcode}} {{city}}\n{{country}} $egypt->getInternationalPrefix(); $egypt->getAddressFormat(); // 357994 // H2 $egypt->getGeonameid(); $egypt->getEdgar(); // EGY // ua $egypt->getItu(); $egypt->getMarc(); // EG // ET $egypt->getWmo(); $egypt->getDs(); // EGY // EG $egypt->getFifa(); $egypt->getFips(); // 40765 // EGY $egypt->getGaul(); $egypt->getIoc(); // EGY // 651 $egypt->getCowc(); $egypt->getCown(); // 59 // 469 $egypt->getFao(); $egypt->getImf(); // MAF // null $egypt->getAr5(); $egypt->isEuMember(); // null // 🇪🇬 $egypt->getVatRates(); $egypt->getEmoji(); // GeoJson data returned as string // SVG data returned as string $egypt->getGeoJson(); $egypt->getFlag(); // Divisions returned as array // {"official":"جمهورية مصر العربية","common":"مصر"} $egypt->getDivisions(); $egypt->getTranslation(); // {"ara":{"official":"جمهورية مصر العربية","common":"مصر"}} $egypt->getNativeNames(); // {"iso_4217_code":"EGP","iso_4217_numeric":818,"iso_4217_name":"Egyptian Pound","iso_4217_minor_unit":2} $egypt->getCurrency(); // {"EGP":{"iso_4217_code":"EGP","iso_4217_numeric":818,"iso_4217_name":"Egyptian Pound","iso_4217_minor_unit":2}} $egypt->getCurrencies(); // {"ara":{"official":"جمهورية مصر العربية","common":"مصر"},"cym":{"official":"Arab Republic of Egypt","common":"Yr Aifft"},"deu":{"official":"Arabische Republik Ägypten","common":"Ägypten"},"fra":{"official":"République arabe d'Égypte","common":"Égypte"},"hrv":{"official":"Arapska Republika Egipat","common":"Egipat"},"ita":{"official":"Repubblica araba d'Egitto","common":"Egitto"},"jpn":{"official":"エジプト·アラブ共和国","common":"エジプト"},"nld":{"official":"Arabische Republiek Egypte","common":"Egypte"},"por":{"official":"República Árabe do Egipto","common":"Egito"},"rus":{"official":"Арабская Республика Египет","common":"Египет"},"spa":{"official":"República Árabe de Egipto","common":"Egipto"},"fin":{"official":"Egyptin arabitasavalta","common":"Egypti"}} $egypt->getTranslations(); // {"continent":{"AF":"Africa"},"postal_code":true,"latitude":"27 00 N","latitude_dec":"26.756103515625","longitude":"30 00 E","longitude_dec":"29.86229705810547","max_latitude":"31.916667","max_longitude":"36.333333","min_latitude":"20.383333","min_longitude":"24.7","area":1002450,"region":"Africa","subregion":"Northern Africa","world_region":"EMEA","region_code":"002","subregion_code":"015","landlocked":false,"borders":["ISR","LBY","SDN"],"independent":"Yes"} $egypt->getGeodata(); // {"geonameid":357994,"edgar":"H2","itu":"EGY","marc":"ua","wmo":"EG","ds":"ET","fifa":"EGY","fips":"EG","gaul":40765,"ioc":"EGY","cowc":"EGY","cown":651,"fao":59,"imf":469,"ar5":"MAF","address_format":"{{recipient}}\n{{street}}\n{{postalcode}} {{city}}\n{{country}}","eu_member":null,"vat_rates":null,"emoji":"🇪🇬"} $egypt->getExtra(); // {"name":"Al Iskandariyah","alt_names":["El Iskandariya","al-Iskandariyah","al-Iskandarīyah","Alexandria","Alexandrie","Alexandria"],"geo":{"latitude":31.2000924,"longitude":29.9187387,"min_latitude":31.1173177,"min_longitude":29.8233701,"max_latitude":31.330904,"max_longitude":30.0864016}} $egypt->getDivision("ALX");
注意:当检索单个国家时,您将获得与上一个示例相同的完整国家详情。但当检索所有国家时,您将获得一个包含常用国家详情的精选结果集,以提高性能。
功能说明
- 国家数据存储在这里:
resources/data/countries.json
。 名称
common
- 英语中的通用名称official
- 英语中的官方名称native
- 所有本地名称列表- 键:三个字母的ISO 639-3语言alpha代码
- 值:名称对象
- 键:
official
- 官方名称翻译 - 键:
common
- 通用名称翻译
- 键:
demonym
- 居民名称capital
- 首都城市iso_3166_1_alpha2
- ISO 3166-1 alpha-2代码iso_3166_1_alpha3
- ISO 3166-1 alpha-3代码iso_3166_1_numeric
- ISO 3166-1数字代码currency
- ISO 4217货币代码(s)- 键:三个字母的ISO 4217货币代码
- 值:货币对象
- 键:
iso_4217_code
- 三个字母的ISO 4217货币alpha代码 - 键:
iso_4217_numeric
- 三个数字的ISO 4217货币numeric代码 - 键:
iso_4217_name
- 官方的ISO 4217货币名称 - 键:
iso_4217_minor_unit
- 小数货币单位
- 键:
tld
- 国家顶级域名alt_spellings
- 替代拼写languages
- 官方语言列表- 键:三个字母的ISO 639-3语言代码
- 值:英语中的语言名称
translations
- 名称翻译列表- 键:三个字母的ISO 639-3语言代码
- 值:名称对象
- 键:
official
- 官方名称翻译 - 键:
common
- 通用名称翻译
- 键:
geo
continent
- 国家所在的洲- key: 双字母洲代码
- value: 英语洲名
postal_code
- 国家是否使用邮政编码latitude
- 纬度坐标点的简写形式latitude_desc
- 纬度坐标点的描述longitude
- 经度坐标点的简写形式longitude_desc
- 经度坐标点的描述max_latitude
- 最大纬度坐标点max_longitude
- 最大经度坐标点min_latitude
- 最小纬度坐标点min_longitude
- 最小经度坐标点area
- 面积,单位为km²region
- 地理区域subregion
- 地理子区域world_region
- 地理世界区域region_code
- 地理区域数字代码subregion_code
- 地理子区域数字代码landlocked
- 是否内陆borders
- 陆地边界independent
- 独立状态
dialling
calling_code
- 电话区号national_prefix
- 国家前缀national_number_lengths
- 国家号码长度national_destination_code_lengths
- 国家目的地代码长度international_prefix
- 国际前缀
extra
geonameid
- 地名词典IDedgar
- 电子数据收集、分析和检索系统itu
- 国际电信联盟分配的代码marc
- 美国国会图书馆的MAchine-Readable Cataloging代码wmo
- 世界气象组织的国家缩写ds
- 国际交通中车辆的识别标志fifa
- 国际足球联合会分配的代码fips
- 美国联邦信息处理标准代码gaul
- 联合国粮食及农业组织全球行政单元层ioc
- 国际奥委会分配的代码cowc
- 战争相关特征cown
- 战争相关数字fao
- 联合国粮食及农业组织imf
- 国际货币基金组织ar5
- 第五次评估报告(AR5)address_format
- 地址格式eu_member
- 欧盟成员国vat_rates
- 增值税税率emoji
- 表情符号国旗
数据来源
- 货币数据(2016年9月27日):http://www.currency-iso.org
- 表情符号国旗(2016年9月27日):http://unicode.org/emoji/charts/full-emoji-list.html
- 世界边界(2016年9月27日):http://thematicmapping.org/downloads/world_borders.php
- GeoJson & SVG国旗(2016年9月27日):https://github.com/mledoze/countries/tree/master/data
- 主要国家数据、地区和划分(2016年9月27日):https://github.com/hexorx/countries
- 其他资源
- https://en.wikipedia.org
- https://github.com/annexare/Countries
- https://github.com/umpirsky/country-list
- https://github.com/datasets/country-list
- https://github.com/datasets/country-codes
- https://github.com/sripaulgit/country-codes
- https://github.com/alexrabarts/iso_country_codes
- https://github.com/vincentarelbundock/countrycode
- https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes
升级
-
从
v2.x
升级到v3.x
没有重大更改,API 保持不变,具有100%的向后兼容性。注意,现在最低要求为 PHP v7.0。
-
从
v1.x
升级到v2.x
整个包从头开始重写,只需删除任何之前的代码,开始使用新的干净直观的API。
变更日志
请参阅项目的完整历史记录,请参考变更日志。
支持
以下支持渠道随时可用
贡献 & 协议
感谢您考虑为此项目做出贡献!贡献指南可在CONTRIBUTING.md中找到。
欢迎提交错误报告、功能请求和拉取请求。
安全漏洞
如果您在此项目中发现安全漏洞,请发送电子邮件至help@rinvex.com。所有安全漏洞都将得到及时处理。
关于Rinvex
Rinvex是一家成立于埃及亚历山大的软件解决方案初创公司,自2016年6月成立以来,致力于为中小企业提供集成企业解决方案。我们相信,我们的动力是“价值、影响力和影响力”,这是我们与众不同的地方,通过软件的力量释放我们哲学的无限可能性。我们喜欢称之为“生活的速度创新”。这就是我们如何为人类进步做出自己的贡献。
许可
本软件在MIT许可(MIT)下发布。
(c) 2016-2018 Rinvex LLC,部分版权所有。