teltek / doctrine-extensions
Doctrine2 behavioral extensions
Requires
- php: >=5.3.2
- behat/transliterator: ~1.0
- doctrine/common: ~2.4
Requires (Dev)
- doctrine/mongodb-odm: >=1.0.0-BETA11
- doctrine/orm: ~2.4
- phpunit/phpunit: ~4.4
- phpunit/phpunit-mock-objects: ~2.3
- symfony/yaml: ~2.3
Suggests
- doctrine/mongodb-odm: to use the extensions with the MongoDB ODM
- doctrine/orm: to use the extensions with the ORM
This package is auto-updated.
Last update: 2024-11-14 21:11:40 UTC
README
This package contains extensions for Doctrine ORM and MongoDB ODM that offer new functionality or tools to use Doctrine more efficiently. These behaviors can be easily attached to the event system of Doctrine and handle the records being flushed in a behavioral way.
⚠️ The master
branch is for development on Doctrine Extensions 3.0.
3.0 will focus on refreshing this package for today's PHP. This includes:
- Bumping minimum version requirements of PHP, Doctrine, and other dependencies
- Updating the test suite, add code and style standards, and other needed build tools
- Cleaning up documentation, code, comments, etc.
While major code changes are not expected initially for 3.0, it will be a major release due to changes in requirements and toolsets.
For the current stable version, see the v2.4.x branch.
Installation
$ composer require gedmo/doctrine-extensions
Upgrading
Extensions
ORM & MongoDB ODM
- 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.
- Sluggable - urlizes your specified fields into single unique slug
- Timestampable - updates date fields on create, update and even property change.
- Translatable - gives you a very handy solution for translating records into different languages. Easy to setup, easier to use.
- Tree - automates the tree handling process and adds some tree-specific functions on repository. (closure, nested set or materialized path) (MongoDB ODM only supports materialized path)
ORM Only
- IpTraceable - inherited from Timestampable, sets IP address instead of timestamp
- SoftDeleteable - allows to implicitly remove records
- Sortable - makes any document or entity sortable
- Uploadable - provides file upload handling in entity fields
MongoDB ODM Only
- References - supports linking Entities in Documents and vice versa
- ReferenceIntegrity - constrains ODM MongoDB Document references
All extensions support YAML, Annotation and XML mapping. Additional mapping drivers can be easily implemented using Mapping extension to handle the additional metadata mapping.
Version Compatibility
If you are setting up the Entity Manager without a framework, see the the example to prevent issues like #1310
XML Mapping
XML mapping needs to be in a different namespace, the declared namespace for Doctrine extensions is http://gediminasm.org/schemas/orm/doctrine-extensions-mapping So root node now looks like this:
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"> ... </doctrine-mapping>
XML mapping xsd schemas are also versioned and can be used by version suffix:
- Latest version - http://gediminasm.org/schemas/orm/doctrine-extensions-mapping
- 2.2.x version - http://gediminasm.org/schemas/orm/doctrine-extensions-mapping-2-2
- 2.1.x version - http://gediminasm.org/schemas/orm/doctrine-extensions-mapping-2-1
Running Tests
To set up and run the tests, follow these steps:
- Install Lando, a Docker-based dev environment tool
- Run
lando start
from the project root - Make sure you
composer install
project dependencies - Run
lando php bin/phpunit -c tests
Running the Example
To set up and run example, follow these steps:
- go to the root directory of extensions
- download composer:
wget https://getcomposer.org/composer.phar
- install dev libraries:
php composer.phar install
- edit
example/em.php
and configure your database on top of the file - run:
./example/bin/console
orphp example/bin/console
for console commands - run:
./example/bin/console orm:schema-tool:create
to create schema - run:
php example/run.php
to run example
Contributors
Thanks to everyone participating in the development of these great Doctrine extensions!
And especially ones who create and maintain new extensions:
- Lukas Botsch lbotsch
- Gustavo Adrian comfortablynumb
- Boussekeyt Jules gordonslondon
- Kudryashov Konstantin everzet
- David Buchmann dbu