vardumper / dom-orm
DOMDocument Object Relational Mapper (ORM)
v1.5.3
2026-10-05 09:30 UTC
Requires
- php: >=8.3 <8.6
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-mbstring: *
- ext-xml: *
- czproject/git-php: ^4.6
- league/config: ^1.2
- league/flysystem: ^2.0|^3.36
- mnapoli/silly: ^1.10.1
- ramsey/collection: ^2.1.1
- ramsey/uuid: ^4.9.4
- symfony/serializer: ^5.4 || ^6.4 || ^7.4 || ^8.1.8
- symfony/yaml: ^5.4 || ^6.4 || ^7.4 || ^8.1.8
Requires (Dev)
- brainmaestro/composer-git-hooks: @dev
- doctrine/orm: ^3.7.3
- fakerphp/faker: ^1.24.1
- friendsofphp/php-cs-fixer: ^3.95.27
- pestphp/pest: ^4.7.8
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^2.2.16
- phpunit/phpunit: ^12.5.33
- rector/swiss-knife: ^2.6.0
- symfony/cache: ^6.4|^7.4.20
- symfony/var-exporter: ^6.4|^7.4.18
- symplify/easy-coding-standard: ^12.6.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
DOM ORM is a lightweight, zero-setup, XML-based persistence layer for small to medium size datasets in PHP projects. It stores entities in a single XML document, allowing you to use relational data without the need to install a database server or driver.
Features
- A PHP-native object-relational-mapper - without the need of a database.
- It operates mainly in-memory to reduce file reads/writes as much as possible.
- For small datasets (<100K), it beats all Doctrine ORM drivers (MariaDB, MySQL, Postgres, SQLite, etc.) in find by ID lookups.
- Very Lightweight, zero-setup persistence — entities live in a single XML file, the single source of truth.
- In-Memory (process runtime), Local file and Remote Storage via Flysystem (S3, Azure, Google Cloud, (S)FTP).
- Relationships: one-to-one, one-to-many, many-to-one, and many-to-many.
- Lazy Resultsets, fast reads, Schema evolution
- Git / Mercurial versioning out of the box.
- Field-level AES-256-GCM encryption via
#[Sensitive], with searchable HMAC hashes. - Export to JSON, YAML, and XML.
- Works with PHP 8.3, 8.4, 8.5 and 8.6
Installation
composer require vardumper/dom-orm
TLDR;
Entity:
// src/Entity/Tag.php use DOM\ORM\Entity\AbstractEntity; use DOM\ORM\Mapping as ORM; #[ORM\Item(entityType: 'tag')] class Tag extends AbstractEntity { public function __construct( #[ORM\Fragment] private string $name ) { parent::__construct(); } }
Persistence:
use DOM\ORM\Traits\EntityManagerTrait; $this->persist(new Tag('Tagname'));
Storage:
<item type="tag" id="e34cbf80edaf490aa39113254b6cdfa9"> <fragment name="name"><![CDATA[Tagname]]></fragment> <fragment name="createdAt"><![CDATA[2024-06-17T06:30:37+00:00]]></fragment> </item>
Query (and hydrate):
$tag = (new EntityRepository(Tag::class))->findOneBy(['name' => 'Tagname']); echo $tag->getName();
Documenation
Extensive Documentation has been made available here.