mohanedghawar/countries-info
Composer 安装命令:
composer require mohanedghawar/countries-info
包简介
A comprehensive PHP library for accessing detailed country information, including regions, capitals, continents, and more.
关键字:
README 文档
README
A comprehensive PHP library for accessing detailed country information, including regions, cities, capitals, continents, and more.
Installation
composer require mohanedghawar/countries-info
Features
- Complete country information (names, codes, capitals, etc.)
- Administrative regions for all countries (states, provinces, etc.)
- Detailed city data including:
- City names and populations
- Geographical coordinates
- Hierarchical organization (Country -> Region -> Cities)
- Population and area data
- Continent information
- Easy-to-use API
- Regular updates
Usage
use MohanedGhawar\CountriesInfo\CountriesInfo; $countriesInfo = new CountriesInfo(); // Get all countries $countries = $countriesInfo->getAllCountries(); // Get country by code $usa = $countriesInfo->getCountryByCode('USA'); // Get country by name $france = $countriesInfo->getCountryByName('France'); // Get countries by continent $europeanCountries = $countriesInfo->getCountriesByContinent('Europe'); // Search countries by name $searchResults = $countriesInfo->searchByName('united'); // Get regions (states/provinces) for a country $usStates = $countriesInfo->getCountryRegions('USA'); // Get cities in a specific region $californiaCities = $countriesInfo->getCitiesByRegion('USA', 'California'); // Get all cities in a country $allUsCities = $countriesInfo->getAllCitiesInCountry('USA'); // Get total number of cities in a country $usCityCount = $countriesInfo->getCityCount('USA'); // Search for cities across all countries $citiesNamedParis = $countriesInfo->searchCities('Paris');
API Reference
Methods
Countries
-
getAllCountries(): arrayReturns an array of all country objects. -
getCountryByCode(string $code): ?arrayReturns a country object for the given 3-letter ISO code (e.g., 'USA', 'GBR'). -
getCountryByName(string $name): ?arrayReturns a country object for the given country name. -
getCountriesByContinent(string $continent): arrayReturns an array of countries in the specified continent. -
searchByName(string $query): arrayReturns an array of countries whose names contain the search term.
Regions
getCountryRegions(string $code): arrayReturns an array of region names for the given country code.
Cities
-
getCitiesByRegion(string $countryCode, string $regionName): arrayReturns an array of city objects for the given country code and region name. -
getAllCitiesInCountry(string $countryCode): arrayReturns an array of city objects for the given country code. -
getCityCount(string $countryCode): intReturns the total number of cities in the given country code. -
searchCities(string $name): arrayReturns an array of city objects whose names contain the search term.
Data Structures
Country Object
[
'name' => [
'common' => 'United States',
'official' => 'United States of America'
],
'code' => 'USA',
'capital' => 'Washington, D.C.',
'continent' => 'North America',
'population' => 331002651,
'area_km2' => 9833517
]
City Object
[
'name' => 'Los Angeles',
'latitude' => '34.05223',
'longitude' => '-118.24368',
'population' => 3971883,
'countryCode' => 'USA', // Only included in searchCities results
'regionName' => 'California' // Only included in searchCities results
]
Regions Array
// Example: $countriesInfo->getCountryRegions('USA') [ 'Alabama', 'Alaska', 'Arizona', // ... all US states 'Wisconsin', 'Wyoming' ]
Data Coverage
- 250+ Countries
- 4,000+ Regions/States
- 150,000+ Cities worldwide
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions, please file an issue on the GitHub repository.
mohanedghawar/countries-info 适用场景与选型建议
mohanedghawar/countries-info 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「geography」 「states」 「countries」 「global」 「international」 「regions」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mohanedghawar/countries-info 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mohanedghawar/countries-info 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mohanedghawar/countries-info 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
List of all countries with names and ISO 3166-1 codes in all languages and data formats for Laravel
PHP extension with Brazilian states and formats for CPF, CNPJ and ZIP
Laravel 5.2 package that provides basic geographical data like Countries, Regions and Cities.
A simple PHP class for United States Postal Service (USPS) addresses
PHP FFI bindings for Uber's H3 hexagonal hierarchical geospatial indexing system
Geo-Toolkit for PHP
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-22