Download the PHP package bvp/prefecture without Composer

On this page you can find all versions of the php package bvp/prefecture. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package prefecture

Prefecture

日本語

php stable license

test psalm audit keepalive 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

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

Usage

Available methods

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

Method Behavior
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

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

Method Behavior
->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

License

Prefecture is open-source software released under the MIT license.


All versions of prefecture with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bvp/prefecture contains the following files

Loading the files please wait ...