Doctrine2 behavioral extensions
Note: Extensions 2.4.x are compatible with ORM and doctrine common library versions from 2.2.x to 2.5.x. ORM 2.5.x versions require PHP 5.4 or higher same as doctrine extensions 3.x.
- Nested tree now allows root field as association.
- From now on, extensions will require php 5.4 or higher.
- All trait column names will refer to naming strategy and won't be explicitly set by extensions.
- Tree repositories are now using traits, for easier extensions.
Extensions and Documentation
This package contains extensions for Doctrine2 that hook into the facilities of Doctrine and offer new functionality or tools to use Doctrine2 more efficiently. This package contains mostly used behaviors which can be easily attached to your event system of Doctrine2 and handle the records being flushed in the behavioral way. List of extensions:
- Tree - this extension automates the tree handling process and adds some tree specific functions on repository. (closure, nestedset or materialized path)
- Translatable - gives you a very handy solution for translating records into different languages. Easy to setup, easier to use.
- Sluggable - urlizes your specified fields into single unique slug
- Timestampable - updates date fields on create, update and even property change.
- Blameable - updates string or reference fields on create, update and even property change with a string or object (e.g. user).
- Loggable - helps tracking changes and history of objects, also supports version management.
- Sortable - makes any document or entity sortable
- Translator - explicit way to handle translations
- SoftDeleteable - allows to implicitly remove records
- Uploadable - provides file upload handling in entity fields
- References - supports linking Entities in Documents and vice versa
- ReferenceIntegrity - constrains ODM MongoDB Document references
- IpTraceable - inherited from Timestampable, sets IP address instead of timestamp
Currently these extensions support Yaml, Annotation and Xml mapping.
Note: Please note, that xml mapping needs to be in a different namespace, the declared namespace for Doctrine extensions is doctrine-extensions.xsd So root node now looks like this:
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-extensions.xsd" xmlns:gedmo="http://Atlantic18.github.io/DoctrineExtensions/schemas/orm/doctrine-extensions.xsd"> ... </doctrine-mapping>
XML mapping xsd schemas are also versioned and can be used by version suffix:
- Latest version - http://Atlantic18.github.io/DoctrineExtensions/schemas/orm/doctrine-extensions.xsd
- 2.4.x version - http://Atlantic18.github.io/DoctrineExtensions/schemas/orm/doctrine-extensions-2.4.xsd
- 3.0.x version - http://Atlantic18.github.io/DoctrineExtensions/schemas/orm/doctrine-extensions-3.0.xsd
ODM MongoDB support
List of extensions which support ODM
- Tree (Materialized Path strategy for now)
All these extensions can be nested together and mapped in traditional ways - annotations, xml or yaml
Running the tests:
pdo-sqlite extension is necessary. To setup and run tests follow these steps:
- install dev libraries:
bin/phpunit -c tests
- optional - run mongodb service if targeting mongo tests
Running the example:
To setup and run example follow these steps:
- go to the root directory of extensions
- install dev libraries:
example/em.phpand configure your database on top of the file
php example/bin/consolefor console commands
./example/bin/console orm:schema-tool:createto create schema
php example/run.phpto run example
Thanks to everyone participating in the development of these great Doctrine2 extensions!
And especially ones who create and maintain new extensions: