定制 lizhineng/region-china 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lizhineng/region-china

最新稳定版本:v1.0.0

Composer 安装命令:

composer require lizhineng/region-china

包简介

China region library for PHP.

README 文档

README

This library helps you manage regional data for mainland China, updated annually based on information from the Ministry of Civil Affairs of the People's Republic of China. The latest update was applied on April 25, 2025.

Installment

The library requires a minimum of PHP 8.2 and can be installed through Composer:

composer require lizhineng/region-china

Usage

The library includes built-in data sourced directly from the authority, so you don't need to maintain it yourself. You can find the update script in the scripts folder. First things first, let's initialize an instance of this helpful library.

use Zhineng\RegionChina\RegionManager;

$regions = RegionManager::createFromBuiltIn();

Resolve the region name from the code

Region codes are good for database persistence, but not very helpful for humans. If you have the region code, you can easily convert it back to the Chinese name.

$regions->getName($beijing = 110000); // 北京市

Retrieve provinces

When creating an interactive multi-level selector for choosing provinces, cities, and districts, it's helpful to first list all provinces in China, allowing you to display the corresponding cities and districts based on the user's selection.

$regions->getTopLevelNodes(); // [110000, 120000, 130000, ...]

Retrieve cities or districts

For example, if you want to list all cities in Guangdong Province or all districts in Guangzhou City, you only need a single API call to retrieve all sub-region codes for the specified area. You can then use these codes to obtain the corresponding names.

// Retrieve city codes for the Guangdong province
$regions->getNodes($guangdong = 440000);

// Retrieve district codes for the Guangzhou city
$regions->getNodes($guangzhou = 440100);

License

The library is released under the MIT License.

统计信息

  • 总下载量: 42
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固