- Avoid #[OneToOne] relationships (performance issue)
- Beware of Entity Inheritance (performance issue)
- Do not introduce complex logic to
$entity->get*EntityIdentifier*(performance issue) - Private methods do not trigger
Doctrine\ORM\Proxy->__load(consistency failure) - Do not reassign Collections, use
$collection->clear()(consistency issue) - Beware of cascade persist (consistency issue)
- Do not introduce
__toString()on Entity classes (consistency issue)
All examples include the Problem subdirectory with the code that will fail and the Solution subdirectory with the code that will work.
Check tests directory for the tests that prove the examples.
- Abstract classes must be part of
#[DiscriminatorMap]even though they are in the middle of hierarchy (doctrine/orm#9142) - Avoid Collection::matching (https://rnd.shipmonk.com/avoid-using-doctrines-collectionmatching-method)
In order to understand the issues, you need to understand how Doctrine works. Most issues are either related to lib/Doctrine/ORM/UnitOfWork or generated proxies.
To see generated proxies, run vendor/bin/doctrine orm:generate-proxies and then check the var/cache/doctrine/ directory.
You need docker and docker compose v2 installed.
printf "UID=$(id -u)\nGID=$(id -g)" > .env(optional, sets up permissions for the shared folders on linux. Requires direnv to apply automatically)docker compose up -ddocker compose run -it app bashcomposer install && composer prepare-databasecomposer test-> Some tests are supposed to fail, you're supposed experiment with those cases individually