PHPackages                             siganushka/region-bundle - 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. [Framework](/categories/framework)
4. /
5. siganushka/region-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

siganushka/region-bundle
========================

Region bundle for symfony.

1.1.0(6mo ago)0221MITPHPPHP &gt;=8.1CI passing

Since Nov 17Pushed 4w ago1 watchersCompare

[ Source](https://github.com/siganushka/region-bundle)[ Packagist](https://packagist.org/packages/siganushka/region-bundle)[ Docs](https://github.com/siganushka/region-bundle)[ RSS](/packages/siganushka-region-bundle/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (7)Versions (12)Used By (0)

Region bundle for symfony
=========================

[](#region-bundle-for-symfony)

[![Build Status](https://github.com/siganushka/region-bundle/actions/workflows/ci.yaml/badge.svg)](https://github.com/siganushka/region-bundle/actions/workflows/ci.yaml)[![Latest Stable Version](https://camo.githubusercontent.com/843e3ad6e34ee4cc258d98dd2aefa6f0e0fcac08e60020f87ee0caf59da53ad7/68747470733a2f2f706f7365722e707567782e6f72672f736967616e7573686b612f726567696f6e2d62756e646c652f762f737461626c65)](https://packagist.org/packages/siganushka/region-bundle)[![Latest Unstable Version](https://camo.githubusercontent.com/760cec6fd0606450fe91b00baf9da6157de99dfad50f4d71e8c6fceba7b9f05c/68747470733a2f2f706f7365722e707567782e6f72672f736967616e7573686b612f726567696f6e2d62756e646c652f762f756e737461626c65)](https://packagist.org/packages/siganushka/region-bundle)[![License](https://camo.githubusercontent.com/368c687dca1c27eb772879ffa303b010d2aa22c7b2608a359123a5aab009fc66/68747470733a2f2f706f7365722e707567782e6f72672f736967616e7573686b612f726567696f6e2d62756e646c652f6c6963656e7365)](https://packagist.org/packages/siganushka/region-bundle)

国内行政区划四级联动 [Bundle](https://symfony.com/doc/current/bundles.html)，数据来源 [Administrative-divisions-of-China](https://github.com/modood/Administrative-divisions-of-China)

### 说明

[](#说明)

- 一级：省、自治区、直辖市
- 二级：市、县、自治州、自治县
- 三级：区、县
- 四级：乡镇/街道

### 安装

[](#安装)

```
$ composer require siganushka/region-bundle
```

### 使用

[](#使用)

更新数据库映射信息：

```
$ php bin/console doctrine:schema:update --force
```

导入行政区划数据：

```
$ php bin/console siganushka:region:update
```

> 默认导入 3 级数据，可使用 `--level=2/3/4` 参数自定义数据等级。

导入路由：

```
# ./config/routes.yaml

siganushka_region:
    resource: "@SiganushkaRegionBundle/config/routes.php"
    prefix: /api
```

> 导入后可通过 `php bin/console debug:route` 查看已导入路由。

### 示例

[](#示例)

实体对象：

```
// src/Entity/UserAddress.php

use Siganushka\RegionBundle\Entity\Region;

class UserAddress
{
    #[ORM\ManyToOne]
    #[ORM\JoinColumn('province_code', referencedColumnName: 'code')]
    private ?Region $province = null;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn('city_code', referencedColumnName: 'code')]
    private ?Region $city = null;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn('district_code', referencedColumnName: 'code')]
    private ?Region $district = null;

    #[ORM\ManyToOne]
    #[ORM\JoinColumn('street_code', referencedColumnName: 'code')]
    private ?Region $street = null;

    // ...
}
```

> 注意 `Region` 主键为 `code`，同时为保证独立和可复用性，关联时必需为单向关系，不要指定 `inversedBy` 参数。

表单类型：

```
// src/Form/UserAddressType.php

use Siganushka\RegionBundle\Form\Type\RegionType;

class UserAddressType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('province', RegionType::class, [
                'cascader_target' => 'city',
            ])
            ->add('city', RegionType::class, [
                'cascader_target' => 'district',
            ])
            ->add('district', RegionType::class, [
                'cascader_target' => 'street',
            ])
            ->add('street', RegionType::class)
        ;
    }

    // ...
}
```

> 选项 `cascader_target` 指定了要联动的下一级字段，不管是二级、三级还是四级，只需要指定该参数即可。前端联动效果由 [AssetMapper](https://symfony.com/doc/current/frontend/asset_mapper.html) 和 [StimulusBundle](https://symfony.com/bundles/StimulusBundle/current/index.html) 实现。

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance82

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community7

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

Recently: every ~377 days

Total

11

Last Release

197d ago

Major Versions

0.6.1 → 1.0.02025-05-08

PHP version history (3 changes)v0.2.0PHP &gt;=7.2.5

v0.6.0PHP &gt;=7.4

1.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/45844370?v=4)[Siganushka](/maintainers/siganushka)[@siganushka](https://github.com/siganushka)

---

Top Contributors

[![siganushka](https://avatars.githubusercontent.com/u/45844370?v=4)](https://github.com/siganushka "siganushka (182 commits)")

---

Tags

symfony-uxregion-bundle

### Embed Badge

![Health badge](/badges/siganushka-region-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/siganushka-region-bundle/health.svg)](https://phpackages.com/packages/siganushka-region-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M374](/packages/easycorp-easyadmin-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k16.8k](/packages/prestashop-prestashop)[kimai/kimai

Kimai - Time Tracking

4.7k8.7k1](/packages/kimai-kimai)[oro/platform

Business Application Platform (BAP)

642140.7k104](/packages/oro-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.7k](/packages/contao-core-bundle)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

51390.8k2](/packages/web-auth-webauthn-framework)

PHPackages © 2026

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