davidbadura/orangedb

This package is abandoned and no longer maintained. No replacement package was suggested.

Readonly Filesystem Database | Object-File Mapping

1.0-alpha11 2019-11-15 18:53 UTC

README

OrangeDB is a library about high performance transition of master data from yaml/json to objects.

Build Status Scrutinizer Code Quality Code Coverage

Installation

You can easily install this package over composer

composer require 'davidbadura/orangedb'

Example

Model

<?php

use DavidBadura\OrangeDb\Annotation as OD;

/**
 * @OD\Document("character")
 */
class Character {
    
    /**
     * @OD\Type("string")
     */
    private $name;
    
    /**
     * @OD\Type("integer")
     */
    private $age;
    
    /**
     * @OD\ReferenceMany("Character")
     */
    private $children;
    
    public function getName(): string 
    {
        return $this->name;
    }
    
    public function getAge(): int 
    {
        return $this->age;
    }
    
    public function getChildren(): array 
    {
        return $this->children;
    }
}

Data

# /var/cache/orangedb/character/sarah.yaml

name: Sarah Connor
age: 32
children: ['john']

# /var/cache/orangedb/character/john.yaml

name: John Connor
age: 8
children: []

Usage

<?php

use DavidBadura\OrangeDb\DocumentManager;
use DavidBadura\OrangeDb\Adapter\YamlAdapter;

$manager = new DocumentManager(new YamlAdapter(__DIR__.'/data'), __DIR__.'/var/cache/orangedb');

$character = $manager->find(Character::class, 'sarah');

echo $character->getName(); // Sarah Connor
echo $character->getAge(); // 32

echo count($character->getChildren()); // 1
echo $character->getChildren()[0]->getName(); //John Connor