PHPackages                             bvp/prefecture - 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. bvp/prefecture

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

bvp/prefecture
==============

Converts between Japanese prefecture/region numbers and names, including kanji, hiragana, katakana, and English variants, backed by native PHP enums.

10.1.0(1mo ago)0130.0k↑31.2%2MITPHPPHP ^8.1CI passing

Since Aug 15Pushed 3w ago1 watchersCompare

[ Source](https://github.com/boatracevibeproject/prefecture)[ Packagist](https://packagist.org/packages/bvp/prefecture)[ RSS](/packages/bvp-prefecture/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (2)Dependencies (7)Versions (15)Used By (2)

Prefecture
==========

[](#prefecture)

[English](README.md) | [日本語](README_ja.md)

[![php](https://camo.githubusercontent.com/47c1434dd3068125716a590fbf3d22a69f530713a8cd97232574eff1c365b3d9/68747470733a2f2f706f7365722e707567782e6f72672f6276702f707265666563747572652f726571756972652f706870)](https://packagist.org/packages/bvp/prefecture)[![stable](https://camo.githubusercontent.com/975eef5dd113fbe137209f85a82283aa34d02094d9390817531c05e427c6c991/68747470733a2f2f706f7365722e707567782e6f72672f6276702f707265666563747572652f762f737461626c65)](https://packagist.org/packages/bvp/prefecture)[![license](https://camo.githubusercontent.com/7600f7acff9e4844818cab503aa96de00975551c6e4c7261c5215a034fec8d1f/68747470733a2f2f706f7365722e707567782e6f72672f6276702f707265666563747572652f6c6963656e7365)](https://packagist.org/packages/bvp/prefecture)

[![test](https://github.com/boatracevibeproject/prefecture/actions/workflows/test.yml/badge.svg)](https://github.com/boatracevibeproject/prefecture/actions/workflows/test.yml)[![psalm](https://github.com/boatracevibeproject/prefecture/actions/workflows/psalm.yml/badge.svg)](https://github.com/boatracevibeproject/prefecture/actions/workflows/psalm.yml)[![audit](https://github.com/boatracevibeproject/prefecture/actions/workflows/audit.yml/badge.svg)](https://github.com/boatracevibeproject/prefecture/actions/workflows/audit.yml)[![keepalive](https://github.com/boatracevibeproject/prefecture/actions/workflows/keepalive.yml/badge.svg)](https://github.com/boatracevibeproject/prefecture/actions/workflows/keepalive.yml)[![dependabot-updates](https://github.com/boatracevibeproject/prefecture/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/boatracevibeproject/prefecture/actions/workflows/dependabot/dependabot-updates)

A small utility library for converting between Japanese prefecture/region numbers, names (kanji, hiragana, katakana, English), and the region each prefecture belongs to — backed by native PHP 8.1 enums.

Why
---

[](#why)

Japan's 47 prefectures show up differently across systems: numeric codes (1–47), full kanji names (青森県), short names (青森), hiragana/katakana readings, or romanized English names (aomori). Converting between these, and resolving which of the 8 regions (地方) a prefecture belongs to, normally means hand-rolling lookup tables scattered across a codebase.

`Prefecture` provides this as a single, tested source of truth, backed by native PHP enums so each prefecture/region is a real, type-safe value you can pass around, compare with `===`, and switch over.

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

[](#installation)

```
composer require bvp/prefecture
```

Usage
-----

[](#usage)

```
use BVP\Prefecture\Prefecture;
use BVP\Prefecture\Region;

Prefecture::from(2); // Enums\Prefecture::aomori
Prefecture::from('青森県'); // Enums\Prefecture::aomori
Prefecture::from('aomori'); // Enums\Prefecture::aomori (case-insensitive)

Prefecture::from(2)->name(); // '青森県'
Prefecture::from(2)->shortName(); // '青森'
Prefecture::from(2)->hiraganaName(); // 'あおもりけん'
Prefecture::from(2)->katakanaName(); // 'アオモリケン'
Prefecture::from(2)->englishName(); // 'aomori'
Prefecture::from(2)->region(); // Enums\Region::tohoku

Region::from('東北'); // Enums\Region::tohoku
Region::from('tohoku')->prefectures(); // [aomori, iwate, miyagi, akita, yamagata, fukushima]

json_encode(Prefecture::from(2));
// {"number":2,"name":"青森県","short_name":"青森", ... }
```

### Available methods

[](#available-methods)

`Prefecture` and `Region` (both under `BVP\Prefecture`) expose the same three lookup methods:

MethodBehavior`Prefecture::from($value)` / `Region::from($value)`Resolves by number or name (number lookup takes priority; see below)`Prefecture::fromNumber(int $number)` / `Region::fromNumber(int $number)`Resolves by number only (1–47 / 1–8)`Prefecture::fromName(string $name)` / `Region::fromName(string $name)`Resolves by any name variant (kanji, short, hiragana, katakana, or English; English matching is case-insensitive)All lookup methods return `null` when no match is found.

**Note on priority:** `from()` always tries the value as a number first. `Prefecture::from('13')` resolves to prefecture number 13 (Tokyo), not a prefecture literally named `"13"`.

> **Deprecated:** `Prefecture::fromRegion()`, `fromRegionNumber()`, and `fromRegionName()` still work but delegate to the `Region` class above and will be removed in the next major version. Use `Region::from()` / `fromNumber()` / `fromName()` instead.

### Enum methods

[](#enum-methods)

Once resolved, `BVP\Prefecture\Enums\Prefecture` and `BVP\Prefecture\Enums\Region` cases expose:

MethodBehavior`->toArray()`All name variants as an array (and, for `Prefecture`, its region's name variants too)`->name()` / `->shortName()` / `->hiraganaName()` / `->katakanaName()` / `->englishName()`The corresponding name variant`Prefecture->region()`The `Region` case this prefecture belongs to`Region->prefectures()`All `Prefecture` cases belonging to this region, in number order`->jsonSerialize()`Same shape as `toArray()`; used automatically by `json_encode()` since both enums implement `JsonSerializable`What it does not do
-------------------

[](#what-it-does-not-do)

- It does not cover municipalities (市区町村) or any administrative unit below the prefecture/region level.
- It does not track historical administrative changes; only the current 47 prefectures and 8 regions are represented.

License
-------

[](#license)

Prefecture is open-source software released under the [MIT license](LICENSE).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance95

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.1% 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 ~67 days

Total

6

Last Release

31d ago

Major Versions

5.x-dev → 6.0.02025-12-31

6.x-dev → 10.0.02026-07-06

PHP version history (2 changes)5.3.0PHP ^8.2

10.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12474425?v=4)[Yuichi Shimo](/maintainers/shimomo)[@shimomo](https://github.com/shimomo)

---

Top Contributors

[![shimomo](https://avatars.githubusercontent.com/u/12474425?v=4)](https://github.com/shimomo "shimomo (154 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

japanjapanesephpprefectureprefectureslibraryboatraceprefecture

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bvp-prefecture/health.svg)

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

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

69939.1M148](/packages/league-iso3166)[dekor/php-array-table

PHP Library for printing associative arrays as text table (similar to mysql terminal console)

348.2M4](/packages/dekor-php-array-table)

PHPackages © 2026

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