Search by

survos / omc

tacman1123

MovieLabs OMC 2.8 DTOs, schema validation and production catalog JSON.

Package info

github.com/survos/omc

pkg:composer/survos/omc

Fund package maintenance!

kbond

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.45.89 2026-11-24 16:59 UTC

This package is auto-updated.

Last update: 2026-11-25 11:25:55 UTC


README

PHP 8.5 immutable DTOs and lossless JSON catalogs using the pinned MovieLabs OMC 2.8 schema. See resources/upstream/NOTICE.md for the upstream revision and Apache-2.0 attribution. Library code is MIT licensed.

use Survos\Omc\EntityFactory;
use Survos\Omc\Catalog;

$entity = (new EntityFactory())->fromJson($singleEntityJson);
$catalog = new Catalog($documentJson);
$characters = $catalog->entities('Character');

Both entry points validate imported JSON. Typed models expose common fields; value() and jsonSerialize() retain the remaining schema fields, extensions, nulls and empty objects. Catalog indexes scoped identifiers, aliases and native references. Conflicting entity definitions are rejected. External references may remain unresolved. Arbitrary customData is not interpreted as native OMC.

Symfony validation attributes

Entity carries #[OmcDocument], inherited by its DTO subclasses. The constraint uses the same pinned schema, so there is no parallel hand-maintained list of OMC constraints. This also validates DTOs constructed directly rather than imported through the factory. Validation is explicit; attributes alone do not run checks.

use Symfony\Component\Validator\Validation;

$validator = Validation::createValidatorBuilder()->enableAttributeMapping()->getValidator();
$violations = $validator->validate($entity);

Violation paths are JSON pointers from the schema validator. Applications may add Symfony constraints for their own stricter requirements. Collection type annotations remain where PHP has no native generic type syntax.

Run the model tests from the mono root:

vendor/bin/phpunit --bootstrap lib/omc/tests/bootstrap.php lib/omc/tests/ModelTest.php