gedmo / doctrine-extensions
Doctrine behavioral extensions
Installs: 92 842 737
Dependents: 426
Suggesters: 18
Security: 0
Stars: 4 035
Watchers: 83
Forks: 1 268
Open Issues: 68
Requires
- php: ^7.4 || ^8.0
- behat/transliterator: ^1.2
- doctrine/collections: ^1.2 || ^2.0
- doctrine/common: ^2.13 || ^3.0
- doctrine/deprecations: ^1.0
- doctrine/event-manager: ^1.2 || ^2.0
- doctrine/persistence: ^2.2 || ^3.0
- psr/cache: ^1 || ^2 || ^3
- psr/clock: ^1
- symfony/cache: ^5.4 || ^6.0 || ^7.0
Requires (Dev)
- doctrine/annotations: ^1.13 || ^2.0
- doctrine/cache: ^1.11 || ^2.0
- doctrine/dbal: ^3.7 || ^4.0
- doctrine/doctrine-bundle: ^2.3
- doctrine/mongodb-odm: ^2.3
- doctrine/orm: ^2.14.0 || ^3.0
- friendsofphp/php-cs-fixer: ^3.14.0
- nesbot/carbon: ^2.71 || ^3.0
- phpstan/phpstan: ^1.11
- phpstan/phpstan-doctrine: ^1.4
- phpstan/phpstan-phpunit: ^1.4
- phpunit/phpunit: ^9.6
- rector/rector: ^1.1
- symfony/console: ^5.4 || ^6.0 || ^7.0
- symfony/doctrine-bridge: ^5.4 || ^6.0 || ^7.0
- symfony/phpunit-bridge: ^6.0 || ^7.0
- symfony/uid: ^5.4 || ^6.0 || ^7.0
- symfony/yaml: ^5.4 || ^6.0 || ^7.0
Suggests
- doctrine/mongodb-odm: to use the extensions with the MongoDB ODM
- doctrine/orm: to use the extensions with the ORM
Conflicts
- doctrine/annotations: <1.13 || >=3.0
- doctrine/dbal: <3.7 || >=5.0
- doctrine/mongodb-odm: <2.3 || >=3.0
- doctrine/orm: <2.14.0 || 2.16.0 || 2.16.1 || >=4.0
- dev-main / 3.x-dev
- v3.17.1
- 3.17.0
- v3.16.1
- v3.16.0
- v3.15.0
- v3.14.0
- v3.13.0
- v3.12.0
- v3.11.1
- v3.11.0
- v3.10.0
- v3.9.0
- v3.8.0
- v3.7.0
- v3.6.0
- v3.5.0
- v3.4.0
- v3.3.1
- v3.3.0
- v3.2.0
- v3.1.0
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v3.0.0-beta2
- v3.0.0-beta
- v2.4.x-dev
- v2.4.42
- v2.4.41
- v2.4.40
- v2.4.39
- v2.4.38
- v2.4.37
- v2.4.36
- v2.4.35
- v2.4.34
- v2.4.33
- v2.4.32
- v2.4.31
- v2.4.30
- v2.4.29
- v2.4.28
- v2.4.27
- v2.4.26
- v2.4.25
- v2.4.24
- v2.4.23
- v2.4.22
- v2.4.21
- v2.4.20
- v2.4.19
- v2.4.18
- v2.4.17
- v2.4.16
- v2.4.15
- v2.4.14
- v2.4.13
- v2.4.12
- v2.4.11
- v2.4.10
- v2.4.9
- v2.4.8
- v2.4.7
- v2.4.6
- v2.4.5
- v2.4.4
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.12
- v2.3.11
- v2.3.10
- v2.3.9
- v2.3.8
- v2.3.7
- v2.3.6
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- dev-dependabot/github_actions/isbang/compose-action-2.0.2
- dev-php74
- dev-3.0/psalm
- dev-archive/master-2019-03-17
- dev-archive/wip-v2.4.0-2019-03-17
- dev-archive/2.2.x-2019-03-17
This package is auto-updated.
Last update: 2024-10-16 10:40:07 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.
Doctrine Extensions 3.0 Released 🎉
3.0 focuses on refreshing this package for today's PHP. This includes:
- Bumping minimum version requirements of PHP, Doctrine, and other dependencies
- Implementing support for the latest Doctrine MongoDB & Common packages
- Updating the test suite, add code and style standards, and other needed build tools
- Cleaning up documentation, code, comments, etc.
Read the Upgrade Doc for more info.
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 Attribute, XML and Annotation (deprecated) mapping. Additional mapping drivers can be easily implemented using Mapping extension to handle the additional metadata mapping.
Version Compatibility
- DBAL:
^3.2
(for all the extensions) or^4.0
(for all the extensions, except Loggable) - ORM:
^2.14
or^3.0
- MongoDB ODM:
^2.3
If you are setting up the Entity Manager without a framework, see 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 Docker and ensure you have
docker compose
- From the project root, run
docker compose up -d
to start containers in daemon mode - Enter the container via
docker compose exec php bash
(you are now in the root directory:/var/www
) - Install Composer dependencies via
composer install
- Run the tests:
vendor/bin/phpunit
Running the Example
To set up and run example, follow these steps:
- go to the root directory of extensions
- download composer
- install dev libraries:
composer install
- edit
example/em.php
and configure your database on top of the file - run:
php example/bin/console
orphp example/bin/console
for console commands - run:
php example/bin/console orm:schema-tool:create
to create the schema - run:
php example/bin/console app:print-category-translation-tree
to run the example to print the category translation tree
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