These are the official behaviors of Mongator.
- Timestampable: Saves the creation and/or update date in the documents.
- Ipable: Saves the IP from where documents are created and/or saved.
- Sluggable: Saves the slug of a field in the documents.
- Archivable: Saves a document copy from one collection to another.
- Tokenizable: Generates a token on creation.
- Hasable: Generates a hash for given fields/rels/embs from the given document, on update and/or creation.
- AutoIncrementable: Auto incrementable field like AUTO_INCREMENT in MySQL
- Identifiable: Automatically saves an identifier in the document.
- PHP 5.3.x;
- mongator/mongator
The recommended way of installing Mongator Behaviors is through composer. You can see package information on Packagist.
{
"require": {
"mongator/behaviors": "1.0.*"
}
}
On your document definition just add a new array named behaviors, just like this:
'Model\MyCollecion' => array(
'fields' => array(
'title' => 'string',
),
'behaviors' => array(
array('class' => 'Mongator\Behavior\Tokenizable'),
array('class' => 'Mongator\Behavior\Archivable'),
),
),
Tests are in the tests
folder.
To run them, you need PHPUnit.
Example:
$ phpunit --configuration phpunit.xml.dist
MIT, see LICENSE