PHPackages                             wdy/district - 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. wdy/district

ActiveLibrary

wdy/district
============

A district SDK

0.0.1(7y ago)48MITPHP

Since Dec 3Pushed 7y agoCompare

[ Source](https://github.com/First-wang/district)[ Packagist](https://packagist.org/packages/wdy/district)[ RSS](/packages/wdy-district/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

 district
==========

[](#-district-)

 A district SDK. 友好支持Laravel框架

[![Build Status](https://camo.githubusercontent.com/2fab0b6121ae40fd3f1f332be179a2be66ae9a4c039bfbe6ae75aa91a2a03bed/68747470733a2f2f7472617669732d63692e6f72672f46697273742d77616e672f64697374726963742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/First-wang/district)[![StyleCI build status](https://camo.githubusercontent.com/d05c00e8f778c2243d5d73bccd754174e80993149d32cdf4a9d676a24e778c5b/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3136303135303735342f736869656c64)](https://camo.githubusercontent.com/d05c00e8f778c2243d5d73bccd754174e80993149d32cdf4a9d676a24e778c5b/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3136303135303735342f736869656c64)

安装
--

[](#安装)

```
$ composer require wdy/district -vvv
```

配置
--

[](#配置)

在使用本扩展之前，你需要去 高德开放平台 注册账号，然后创建应用，获取应用的 API Key。

用法
--

[](#用法)

```
use Wdy\District\District;

$key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';

$d = new District($key);

$response = $d->getDistrict('成都');
```

结果示例:

```
{
    "status": "1",
    "info": "OK",
    "infocode": "10000",
    "count": "1",
    "suggestion": {
        "keywords": [],
        "cities": []
    },
    "districts": [
        {
            "citycode": "028",
            "adcode": "510100",
            "name": "成都市",
            "center": "104.065735,30.659462",
            "level": "city",
            "districts": []
        }
    ]
}
```

参数说明:

```
getDistrict(string $keywords, int $subdistrict = 0, string $output = 'JSON')
```

$subdistrict参数设置显示下级行政区级数,可选值：0、1、2、3; $output参数设置返回数据格式类型,可选值:JSON、XML

laravel用法:

```
//容器获取方式
app('district')->getDistrict('成都');

//依赖注入方式
public function __construct(District $district)
{
    $this->district = $district;
}
```

鸣谢
--

[](#鸣谢)

[overtrue](https://github.com/overtrue)

License
-------

[](#license)

MIT

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2719d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/31070444077926f20f81c261aab2050aeaa9fbf265e8c4bb5e4cd0013da36960?d=identicon)[First-wang](/maintainers/First-wang)

---

Top Contributors

[![First-wang](https://avatars.githubusercontent.com/u/26293106?v=4)](https://github.com/First-wang "First-wang (12 commits)")

### Embed Badge

![Health badge](/badges/wdy-district/health.svg)

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

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[laravel/browser-kit-testing

Provides backwards compatibility for BrowserKit testing in the latest Laravel release.

5139.4M286](/packages/laravel-browser-kit-testing)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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