PHPackages                             dakalab/division-code - 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. dakalab/division-code

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

dakalab/division-code
=====================

Administrative division codes of China

v2.3.8(5y ago)04261MITPHPPHP &gt;=7CI failing

Since Nov 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/dakalab/division-code)[ Packagist](https://packagist.org/packages/dakalab/division-code)[ RSS](/packages/dakalab-division-code/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (4)Versions (19)Used By (1)

division code
=============

[](#division-code)

[![Build Status](https://camo.githubusercontent.com/09e44e3c92661c04c972846bb5efe4bf5f359a9dfc33df4556e323c494fba374/68747470733a2f2f7472617669732d63692e6f72672f64616b616c61622f6469766973696f6e2d636f64652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dakalab/division-code)[![Codecov](https://camo.githubusercontent.com/908d362a64c74f6ff4aaa4e33ae14e11b3bc75db66e6d0e984e05159a8a82da9/68747470733a2f2f636f6465636f762e696f2f67682f64616b616c61622f6469766973696f6e2d636f64652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/dakalab/division-code)[![Latest Stable Version](https://camo.githubusercontent.com/87bfde4746e6c15ceec1c70b35bd0327879cb783bf2e554670bd6e40c224a23b/68747470733a2f2f706f7365722e707567782e6f72672f64616b616c61622f6469766973696f6e2d636f64652f762f737461626c65)](https://packagist.org/packages/dakalab/division-code)[![Total Downloads](https://camo.githubusercontent.com/b380a6d7acda53794ecc45d33b18283faf30b64cd92731fe8f4924e27ea78303/68747470733a2f2f706f7365722e707567782e6f72672f64616b616c61622f6469766973696f6e2d636f64652f646f776e6c6f616473)](https://packagist.org/packages/dakalab/division-code)[![License](https://camo.githubusercontent.com/0253e80fbe80cf889ccb5e4b38eec68b92addc8262a825da0057b7c2a6094388/68747470733a2f2f706f7365722e707567782e6f72672f64616b616c61622f6469766973696f6e2d636f64652f6c6963656e73652e737667)](https://packagist.org/packages/dakalab/division-code)

Administrative division codes of China ()

This library has two ways of storage: php array file and SQLite3 database, see the benchmark below. The library will automatically detect if your php support SQLite3, if yes then it will use SQLite3, otherwise it will fall back to use php array.

You can also use function `useSQLite($v = true)` to turn on or turn off using SQLite.

Install
-------

[](#install)

```
composer require dakalab/division-code

```

Usage
-----

[](#usage)

```
use Dakalab\DivisionCode\DivisionCode;

$divisionCode = new DivisionCode;
$res = $divisionCode->get('110000'); // 北京市

// Get all the provinces
$provinces = $divisionCode->getAllProvinces();
print_r($provinces);

// Get all the cities in the specified province
$province = '110000';
$cities = $divisionCode->getCitiesInProvince($province);
print_r($cities);

// Get all the counties in the specified city
$city = '445200';
$counties = $divisionCode->getCountiesInCity($city);
print_r($counties);

// Get all the cities in the specified province by the province name
$province = '广东省';
$cities = $divisionCode->getCitiesByProvinceName($province);
print_r($cities);

```

Upgrade
-------

[](#upgrade)

If you want to upgrade the division codes by yourself, you can simply run the `Upgrader`

```
use Dakalab\DivisionCode\Upgrader;

$upgrader = new Upgrader;
$upgrader->upgrade();

```

Benchmark
---------

[](#benchmark)

For a loop of 1000000 calls ran on a MacBook Pro 2.9 GHz Intel Core i5, 8GB 1867 MHz DDR3:

**Use sqlite3**

Time cost: 23.28 s, Memory cost: 15.85 kb

**Use php array**

Time cost: 0.47 s, Memory cost: 287.45 kb

**Conclusion**

SQLite3 uses less memory usage but slower, built-in php array is much faster but costs much more memory.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

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 ~45 days

Recently: every ~75 days

Total

18

Last Release

1956d ago

Major Versions

v1.1.4 → v2.0.02019-07-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/38477a075b41de5a26d8125f39a5075e700472d770024cf31e9e3d1566e0c5e5?d=identicon)[hyperjiang](/maintainers/hyperjiang)

---

Top Contributors

[![hyperjiang](https://avatars.githubusercontent.com/u/12892368?v=4)](https://github.com/hyperjiang "hyperjiang (32 commits)")

---

Tags

citycountydivisionprovince

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/dakalab-division-code/health.svg)

```
[![Health](https://phpackages.com/badges/dakalab-division-code/health.svg)](https://phpackages.com/packages/dakalab-division-code)
```

###  Alternatives

[razorpay/slack-laravel

Laravel 4 and 5 integration for the razorpay/slack package, including facades and service providers.

18375.3k1](/packages/razorpay-slack-laravel)

PHPackages © 2026

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