Getting Started


A content repository helps bridge the gap between simple object models and complex domain logic.

Object Relational Mapping has been famously described as the Vietnam of Computer Science, but thanks to Martin Fowler's landmark Patterns of Enterprise Application Architecture and open source projects like Hibernate, Ruby on Rails, Django, SQLAlchemy, and Propel, we may have lived through the worst of the Tet Offensive to see the dawn of a less frightening era of Domain Driven Design. The exit strategy is straightforward: utilization of dynamically typed reflective languages and the twin beacons of convention over configuration and bi-directional code generation (reversibility).

In short, there is nothing to be gained from being dogmatic about ORM approaches. The debate can't go much deeper than the relatively trite observation of 'using the right tool for the job'. CMS applications or CRUD heavy business tools will benefit most from active record style abstractions. Effectively presenting large sequences, search spaces, or working with complex relational data, may require a different approach. As always with programming, you should focus on choosing the most appropriate data structure for the job.

In terms of approach, Floe's schema declarations are closest in meaning and intent to those of Django, although there are significant differences.

The Record Type

Most usages of Floe will involve a database backed storage layer with a domain model defined as a set of active record objects, represented by subtypes of Record and Relationship. Implementations should start with a diagram sketch of significant domain objects:

Page
shortname
title
content
belongs to: section
Section
shortname
title
summary
has many: pages
 

This model can be defined in PHP code as:

class Page extends Record {
    function __define() {
        $this->property('shortname', 'string');
        $this->property('title', 'string');
        $this->property('content', 'text');
        $this->belongsTo('section');
    }
}
class Section extends Record {
    function __define() {
        $this->property('shortname', 'string');
        $this->property('title', 'string');
        $this->property('summary', 'text');
        $this->hasMany('pages');
    }
}

As you'd expect, firing up this model at runtime is easy:

// create a new Page record
$page = new Page();
$page->shortname = 'contact-us';
$page->title = 'Contact Us';
$page->content = 'Please contact us for more info';
 
// create a new Section record
$section = new Section();
$section->shortname = 'about';
$section->title = 'About';
$section->summary = 'The About section of our website';
$page->section = $section;
 
// save the Page record
// (recursively saves the associated Section)
$page->save();

The current state of this documentation is woefully inadequate. But at least the HTML/CSS template exists! See the model unit tests for more clues as to what this package is capable of.


Related Documentation