PHPackages                             slince/china - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. slince/china

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

slince/china
============

中国资料库查询大全

1.1.0(4y ago)5543617[1 issues](https://github.com/slince/China/issues)MITPHPPHP ^7.2||^8.0

Since Nov 9Pushed 4y ago4 watchersCompare

[ Source](https://github.com/slince/China)[ Packagist](https://packagist.org/packages/slince/china)[ RSS](/packages/slince-china/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

 [![中国](https://raw.githubusercontent.com/slince/china/master/etc/china.png)](https://raw.githubusercontent.com/slince/china/master/etc/china.png)

我国的资料库查询库；本库主要包含民族、节日、地址库信息的查询；部分数据来源采集自百科以及国家统计局；欢迎收藏欢迎贡献代码；

[![Build Status](https://camo.githubusercontent.com/738146f8981ca78aca497cfa4988034de4033b406b8a81bd6d96e6a182b1b712/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f736c696e63652f4368696e612f746573743f7374796c653d666c61742d737175617265)](https://github.com/slince/China/actions)[![Coverage Status](https://camo.githubusercontent.com/587cc0d3bcf986d356aee4f0996f5f05a2820e06854c1e598ecd48d55f453f56/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f736c696e63652f4368696e612f6d61737465723f7374796c653d666c61742d737175617265)](https://codecov.io/github/slince/China)[![Latest Stable Version](https://camo.githubusercontent.com/0a4ad3efa6bd9b215aa9d5def152602692c57ab48ed5571c0653d442e034d931/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c696e63652f6368696e612e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/slince/china)[![Scrutinizer](https://camo.githubusercontent.com/8c9433ac4abfbc41ce15ae1633d51810e9f76abde783f00cf4b9088d099529d7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736c696e63652f4368696e612e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/slince/China/?branch=master)

Installation
------------

[](#installation)

执行下面命令安装

```
> composer require slince/china
```

Document
--------

[](#document)

你可以在这里发现[文档](./doc);

Basic Usage
-----------

[](#basic-usage)

### 节日查询

[](#节日查询)

```
$china = new China();

$holidayService = $chna->getHoliday();

print_r($holidayService->findAll());
```

按名称查找节日

```
$yuandan = $holidayService->find('元旦节'):

 echo $yuandan->getDate(); //输出 1月1日
```

### 民族查询

[](#民族查询)

```
$china = new China();

$nationalityService = $chna->getNationality();

print_r($nationalityService->findAll());
```

按名称查找

```
$hezhe = $nationalityService->find('赫哲族'):

 echo $hezhe->getPinyin(); //输出“hè zhé zú”
 echo $hezhe->getPopulation(); //输出人口
```

### 地址库查询

[](#地址库查询)

```
$china = new China();

$regionService = $china->getRegion();

print_r($regionService->getProvinces()); //获取树形省市县地区结构
```

按名称查找地区

```
$bengbushi = $regionService->findByName('蚌埠市');
echo $bengbushi->getParent()->getName(); //输出蚌埠市所属省， 安徽省
```

查询身份证所在地

```
$huaiyuan = $regionService->findByIdCard('340321199212026972');
```

地区链功能

通过`AddressInterface`的`getParent()`和`getChildren()`方法你可以自由地查找当前地区的上级或者下级地区，下级地区集合是`RegionCollectionInterfaec`实例；

```
$yuhuiqu = $bengbushi->getChildren()->findByName('禹会区'); //蚌埠市下属禹会区
$yuhuiqu->getParent()->getChildren()->findByName('淮上区'); //禹会区同级淮上区
```

Json Serialize

```
$bengbushi = $regionService->findByName('蚌埠市');
echo json_encode($bengbushi);
```

上述代码会输出蚌埠市及其下属地区的完整的json树形结构；如果你不需要的话下级地区的话请将children设置为空

```
$bengbushi = $regionService->findByName('蚌埠市');
$bengbushi = clone $bengbushi; //此处需要克隆对象，如果直接修改会破坏原有的地区树结构
$bengbushi->setChildren([]);
echo json_encode($bengbushi);
```

> 建议：在电商系统中城市县三级地区联动的数据可以使用此方法获取，避免将数据导入数据库再从数据库获取；

命令行工具
-----

[](#命令行工具)

执行下面命令查看支持的所有命令

```
$ china list
```

输出信息：

```
Available commands:
  help                   Displays help for a command
  list                   Lists commands
 crawl
  crawl:holiday          采集节假日数据
  crawl:nationality      从百度百科采集民族信息
  crawl:region           从国家统计局采集地区信息
 view
  view:holiday      展示节假日信息
  view:nationality  展示民族数据信息
  view:region       展示我国省市县信息

```

例: 展示我国所有的省、直辖市、自治区以及特别行政区：

```
$ china  dashboard:region
```

上述命令会输出以下结果：

```
 -------- ------------------ ------
  Code     名称               类型
 -------- ------------------ ------
  110000   北京市             省
  120000   天津市             省
  130000   河北省             省
  140000   山西省             省
  150000   内蒙古自治区       省
  210000   辽宁省             省
  220000   吉林省             省
  230000   黑龙江省           省
  310000   上海市             省
  320000   江苏省             省
  330000   浙江省             省
  340000   安徽省             省
  350000   福建省             省
  360000   江西省             省
  370000   山东省             省
  410000   河南省             省
  420000   湖北省             省
  430000   湖南省             省
  440000   广东省             省
  450000   广西壮族自治区     省
  460000   海南省             省
  500000   重庆市             省
  510000   四川省             省
  520000   贵州省             省
  530000   云南省             省
  540000   西藏自治区         省
  610000   陕西省             省
  620000   甘肃省             省
  630000   青海省             省
  640000   宁夏回族自治区     省
  650000   新疆维吾尔自治区   省
  710000   台湾省             省
  810000   香港特别行政区     省
  820000   澳门特别行政区     省
 -------- ------------------ ------

```

...

License
-------

[](#license)

The MIT license. See [MIT](https://opensource.org/licenses/MIT)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1590 days

Total

2

Last Release

1514d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6.0

1.1.0PHP ^7.2||^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3785826?v=4)[Tao](/maintainers/slince)[@slince](https://github.com/slince)

---

Top Contributors

[![slince](https://avatars.githubusercontent.com/u/3785826?v=4)](https://github.com/slince "slince (55 commits)")

---

Tags

addresschinachina-addresschina-regionholidaysnationalityregionregionsChina

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/slince-china/health.svg)

```
[![Health](https://phpackages.com/badges/slince-china/health.svg)](https://phpackages.com/packages/slince-china)
```

###  Alternatives

[wallabag/wallabag

open source self hostable read-it-later web application

12.6k2.2k](/packages/wallabag-wallabag)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[medz/gb-t-2260

中华人民共和国国家标准 GB/T 2260 行政区划代码

10663.6k5](/packages/medz-gb-t-2260)[alicfeng/identity-card

IdentityCard Library

1228.5k](/packages/alicfeng-identity-card)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
