Skip to content

An ORM agnostic model (object / view / form) configuration library.

License

Notifications You must be signed in to change notification settings

reyostallenberg/FlexModel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlexModel

Latest version on Packagist Software License Build Status Coverage Status SensioLabsInsight

An ORM agnostic model (object / view / form) configuration library.

Installation using Composer

Run the following command to add the package to the composer.json of your project:

$ composer require flexmodel/flexmodel

Usage

Load a FlexModel configuration file:

<?php

use FlexModel\FlexModel;

$domDocument = new DOMDocument('1.0', 'UTF-8');
$domDocument->load('flexmodel.xml');

$flexModel = new FlexModel();
$flexModel->load($domDocument, 'path/to/cache/directory');

The FlexModel XML format

A minimal FlexModel object definition consists of an object name and model definition with fields:

<?xml version='1.0' encoding='UTF-8'?>
<flexmodel>
    <object name='TheNameOfTheObject'>
        <fields>
            <field name='name_of_the_field' datatype='VARCHAR'/>
        </fields>
    </object>
</flexmodel>

The object model configuration

The model is defined by one or more field nodes in the fields node of the object, like the example above shows. Each field has a datatype defined and a unique field name.

Field datatypes

These are the various datatypes that can be defined for a field:

  • BOOLEAN
  • DATE
  • DATEINTERVAL
  • DATETIME
  • DECIMAL
  • FILE
  • FLOAT
  • HTML
  • INTEGER
  • JSON
  • TEXT
  • SET
  • VARCHAR

Creating references between objects

References between objects are created by adding a field with an 'OBJECT.ObjectName' datatype.

In the example below you can see an object with the name 'ReferencingObject' with a field refering to an object with the name 'ReferencedObject:

<?xml version='1.0' encoding='UTF-8'?>
<flexmodel>
    <object name='ReferencingObject'>
        <fields>
            <field name='referenced_object' datatype='OBJECT.ReferencedObject'/>
        </fields>
    </object>
    <object name='ReferencedObject'>
        <fields>
            <field name='some_other_field' datatype='VARCHAR'/>
        </fields>
    </object>
</flexmodel>

Credits and acknowledgements

Also see the list of contributors who participated in this project.

About

An ORM agnostic model (object / view / form) configuration library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 78.6%
  • XSLT 21.4%