oihana / php-standards
The Oihana PHP Standards library
1.0.0
2025-08-13 09:29 UTC
Requires
- php: >=8.4
- oihana/php-core: dev-main
- oihana/php-reflect: dev-main
Requires (Dev)
- nunomaduro/collision: ^8.8
- phpunit/phpunit: ^12
README
Oihana PHP β Standards is a library of constants, value-objects and helpers built on top of international standards (ISO, IETF, UN/CEFACT, UN M49).
It is designed for strong typing, validation and easy lookups in your PHP 8.4+ applications.
π Documentation
Full documentation is available in two languages:
- π¬π§ English documentation
- π«π· Documentation franΓ§aise
Quick links: Getting started Β· ConstantsTrait Β· Value-objects Β· Helpers convention
π¦ Installation
Requires PHP 8.4+ (uses property hooks).
composer require oihana/php-standards
π What's inside
| Namespace | Coverage |
|---|---|
org\iso |
ISO 8601 (date/time/duration/interval/recurrence + format), ISO 3166-1, ISO 639-1, ISO 4217, ISO 15924 |
org\ietf |
BCP 47 / RFC 5646 locale tags |
org\unece\uncefact |
UN/CEFACT units of measure (Rec. 20) and package types (Rec. 21) |
org\unstats |
UN M49 country/area codes |
org\common |
Cross-standard format catalogs (date, number) |
π‘ At a glance
use org\iso\ISO4217; use org\iso\Iso8601DateTime; use org\ietf\Locale; // Constants with built-in validation/lookup ISO4217::EUR; // "EUR" ISO4217::includes('XYZ'); // false // ISO 8601 value-objects with property hooks $dt = new Iso8601DateTime('2026-05-14T08:15:30+02:00'); $dt->datePart->year; // 2026 $dt->timePart->hours; // 8 // BCP 47 locales with cross-validation against ISO new Locale('zh-Hant-TW', strict: true); // OK new Locale('zz-ZZ', strict: true); // throws
Many more examples in the documentation.
π License
MPL 2.0 β Mozilla Public License Version 2.0
π€ Author
- Marc ALCARAZ (aka eKameleon)
- π§ marc@ooop.fr
- π https://www.ooop.fr
