delphi / php-orm
ORM for interacting with Graph DB
Installs: 3
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/delphi/php-orm
Requires
- doctrine/annotations: ^1.6
- psr/log: ^1.1
Requires (Dev)
- liip/rmt: ^1.5
- mockery/mockery: ^1.2
- pds/skeleton: ^1.0
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2025-10-23 00:35:28 UTC
README
Basic structure to handle persisting objects in a GraphDB
⚠ Does not handle any sort of data extraction yet. This is effectively write-only for now.
Usage
Setup
// Create a new entity manager, but first we need... // ... a DB client object (See delphi/client-laudis for an *actual* implementation) ... $client = new class implements \delphi\ORM\Client\ClientInterface {}; // ... a QueryBuilder (with its own dependencies) ... $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader(); $annotationDriver = new \delphi\ORM\Driver\AnnotationDriver($annotationReader); $queryBuilder = new \delphi\ORM\QueryBuilder($annotationDriver); $em = new \delphi\ORM\EntityManager($client, $queryBuilder);
Configuration
namespace App; use delphi\ORM\Annotation as OGM; /** * @OGM\Entity(label="Foo") */ class Foo { /** * @OGM\Property(name="name") */ public string $name = ''; /** * @OGM\Relationship(type="CHILD_OF", targetEntity="\App\Bar") */ public Bar $parentBar; }
- Set the object as an
Entity(label="LabelVal")labelis the string to be used as the label inside of the GraphDB
- Set individual properties as a
Property(name="propertyName", unique=true)nameis the name to be given to the propertyuniqueis the optional flag to say a particular property is unique amongst all entities with this label. Defaults tofalse.
- Set relationships as
Relationship(type="RELATIONSHIP_TYPE", targetEntity="\App\Bar", multiple=false)typeis the name given to the edge (relationship) inside of the GraphDBtargetEntityis the PHP class name odf the entity on the other end of the relationshipmultipleis the optional flag to say whether a relationship is 1-to-1 or 1-to-many
Otherwise, entities are plain-old-PHP-objects, and you can do with them what you want.
If you want to have the properties not be public, you can add getter methods for individual properties. See \delphi\ORM\Util\PropertyGetter.
Execution
// Create a new entity... $entity = new Foo(); $entity->name = 'Nombre'; $entity->parentBar = new Bar(); // ... and set it to be persisted $em->persist($entity); // There won't be any DB interactions performed until... // ...actually save the entity off to the DB $em->flush();
This will result in 2 nodes with 1 edge between them.
+---------------+
| Foo |
| name="Nombre" |
+---------------+
|
| CHILD_OF
v
+---------------+
| Bar |
+---------------+