mongator / behaviors
Bahaviors for Mongator, the Simple, powerful and ultrafast Object Document Mapper (ODM) for PHP and MongoDB
Installs: 1 458
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 5
Open Issues: 1
Requires
- php: >=5.3.0
- mongator/mongator: 1.5.*
README
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.
- Stringifiable: Add to the document the magic method __toString, so any document can be converted to string.
- EmbeddedUniquable: Ensure unique embeddeds document in a embeddedsMany relation.
Requirements
- PHP 5.3.x;
- mongator/mongator
Installation
The recommended way of installing Mongator Behaviors is through composer. You can see package information on Packagist.
{ "require": { "mongator/behaviors": "1.4.*" } }
Examples
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
Tests are in the tests
folder.
To run them, you need PHPUnit.
Example:
$ phpunit --configuration phpunit.xml.dist
License
MIT, see LICENSE