cadasto / openehr-bmm
Opinionated PHP library implementing the openEHR Basic Meta-Model (BMM), mostly an intermediate representation of P_BMM specifications.
0.4.0
2026-10-23 22:25 UTC
Requires
- php: ^8.4
- ext-json: *
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.4
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.4
- rector/rector: ^2.4
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Opinionated PHP library implementing the openEHR Basic Meta-Model (BMM). It serves primarily as an intermediate representation (IR) of P_BMM specifications, providing typed PHP objects for schemas, packages, classes, properties, types, and functions.
Features
- Parse openEHR BMM JSON schemas into strongly-typed PHP objects (
BmmSchema,BmmClass,BmmPackage, etc.) - Format-neutral
toArray()/fromArray()on every model, with JSON handled byJsonCodec(models also implementJsonSerializable) - P_BMM class variants: classes, interfaces, and string and integer enumerations
- Property types: single, container, indexed container (
Hash<K, V>), generic, and open single properties - Function definitions with parameters, pre/post-conditions, and result types
- Generic parameter definitions, generic types, open types (
T), and generic inheritance (ancestor_defs) - Typed collections with alias support
Installation
composer require cadasto/openehr-bmm
Quick start
use Cadasto\OpenEHR\BMM\Codec\JsonCodec; use Cadasto\OpenEHR\BMM\Model\BmmSchema; $codec = new JsonCodec(); // Load a BMM schema from a P_BMM JSON file $schema = BmmSchema::fromArray($codec->decodeFile('openehr_rm_1.2.0.bmm.json')); // Access schema metadata echo $schema->getSchemaId(); // "openehr_rm_1.2.0" // Navigate packages and classes foreach ($schema->packages as $package) { echo $package->name . PHP_EOL; } // Serialize back to JSON echo $codec->encode($schema->toArray());
Development
With Docker
make build make install make ci
Without Docker
Requires PHP 8.4 or later. composer test:coverage also needs Xdebug.
composer install composer ci
Composer scripts
| Script | Description |
|---|---|
composer test |
Run PHPUnit |
composer test:dox |
PHPUnit with testdox output |
composer test:coverage |
PHPUnit with HTML coverage report |
composer check:lint |
Parallel-lint (syntax) |
composer check:cs |
PHPCS (PSR-12) |
composer check:phpstan |
PHPStan (level 8) |
composer rector |
Run Rector refactoring |
composer ci |
Run all checks (validate, lint, CS, PHPStan, tests) |
Standards
- Style: PSR-12 (PHPCS)
- Static analysis: PHPStan level 8
- Tests: PHPUnit 13
- Refactoring: Rector (local only)
See docs/testing.md for command details and docs/php-standards.md for standards.
Releases
Tag with SemVer (no v prefix), e.g. git tag 1.0.0 && git push origin 1.0.0. See docs/releases.md.
License
MIT — see LICENSE.