Chaos

— A Domain Modeling Library —

Chaos is an independent, persistence-agnostic layer responsible for defining entities' business logic and relationships. It allows to describe a Domain Model without any assumption about the persitence layer.

Already available persistant layers: * chaos-database: supports MySQL, PostgreSQL and SQLite.

Since Chaos contains all persistence-agnostic logic like relationships, eager/lazy loading, validations, etc. it dramatically simplify the developpment of datasources libraries.

As long as the datasource you envisionned to use is able to fetch a record/document thanks to a unique identifier (i.e no composite primary key), creating a persistant layer for Chaos will be trivial.

Note: The Chaos syntax is derived from li3. If the syntax is not fully compatible with its predecessor, some effort has been made to keep the same clean and beautiful syntax.

Requirements

  • PHP 5.5+

Main Features

  • Support eager/lazy loading
  • Support custom finders
  • Support nested saving
  • Support nested validations
  • Support external & embedded relationship
  • Support custom types & entities' field casting

Example of syntax:

use My\Project\Model\Image;

// Adding a many-to-many relation
$image = Image::load(123);
$image->tags[] = ['name'  =>  'Landscape'];
$image->broadcast();

foreach($image->tags as $tag) { // Echoes: 'Montain', 'Black&White', 'Landscape'
    echo $tag->name;
}

Download

Download Chaos on Github

Documentation

Important: in the following documentation chaos-database is used to illustrate examples. So don't forget to run composer require crysalead/chaos-database in your project before poking around examples.