Download the PHP package vardumper/dom-orm without Composer
On this page you can find all versions of the php package vardumper/dom-orm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vardumper/dom-orm
More information about vardumper/dom-orm
Files in vardumper/dom-orm
Package dom-orm
Short Description DOMDocument Object Relational Mapper (ORM)
License
Informations about the package dom-orm
DOM ORM
This is a storage adapter for small web projects. Like any other ORM, it stores enitites (objects) into a flexible XML file. This is for developers who want to start a small project without having to spin up a database.
Features
- A very lightweight approach to persisting data into a single XML file.
- Supports local and external file storage via Flysystem (S3,Azure,Google Cloud,(S)FTP,etc.)
- Supports Many-to-one, One-to-many and Many-to-many relationships.
Full Documentation
Read the Documentation
Getting started
By default, the XML file is stored on your local filesystem as storage/data.xml
under the root of your project.
You can change the storage location by changing the Flysystem adapter and configuring dom-orm to use it, like so:
Basic Usage
Entity
By adding PHP8 Attributes to your entity class, DOM ORM knows how to persist it.
Persistance
An EntityManagerTrait can be used in controllers or services to persist entities to the XML file.
When you want to update an existing Entity, you can use the persist
method as well.
When you want to remove an existing Entity, you can use the remove
method.
Serialization
When persisting the entity, DOM ORM automatically generates a UID and adds a creation date for the entity. The built-in normalizer and encoder transforms the object into a standardized XML format and saves it.
Querying data
Just like persisting a PHP Object to a XML format, querying data is just as easy. When you query data, internally XPath is used to find the elements, the resulting DOMNodeList is then mapped back to its Entity class object(s).
Querying data with an Entity Repository
By using the EntityRepository class, you can query data in an object-oriented way, always retrieving instances of Entity object(s).
Querying data using DOMXPath
Querying data using DOMDocument
Templating
Twig
Probably the easiest way is to query for entities and pass them to your Twig templates:
Or you could just decoded some DOMElements and pass an array to Twig templates (without instantiating the object):
XSLT
You can use the XML data to transform it into HTML using XSLT.
Roadmap
- [ ] Add support for Many-to-many relationships using hash maps.
- [ ] Add ordering/sorting to the EntityRepository pattern.
- [ ] By providing a GraphQL endpoint, you can interact with your DOM-ORM database in a more flexible, headless way.
- [ ] Adding support for migrations (or rather a cleanup) so that removed fragments are removed from the XML file as well.
- [ ] Add support to encrypt parts or the entire XML file for better security.
All versions of dom-orm with dependencies
ext-dom Version *
ext-json Version *
ext-libxml Version *
ext-mbstring Version *
ext-xml Version *
ramsey/uuid Version ^4.7.6
ramsey/collection Version ^2.0
symfony/serializer Version ^6.4.8 || ^7.1.1
league/flysystem Version ^3.28
symfony/yaml Version ^6.4.8 || ^7.0.0
mnapoli/silly Version ^1.9.0
league/config Version ^1.2