minor #21773 [Uid] Clarify Doctrine UUID generator usage and configuration (lacatoire)

This PR was submitted for the 8.1 branch but it was merged into the 6.4 branch instead.

Discussion
----------

 [Uid] Clarify Doctrine UUID generator usage and configuration

Clarify the difference between using UuidGenerator::class and the doctrine.uuid_generator service when storing UUIDs with Doctrine, and document how to properly use the configured UUID version.
https://github.com/symfony/symfony-docs/issues/21528

Commits
-------

742ce13d0 docs(uid): clarify Doctrine UUID generator usage
This commit is contained in:
Javier Eguiluz
2026-01-30 09:46:57 +01:00

View File

@@ -350,6 +350,19 @@ entity primary keys::
// ...
}
.. note::
When using DoctrineBundle, using ``UuidGenerator::class`` creates a new
generator instance and does **not** use the ``doctrine.uuid_generator``
service. As a result, the UUID version configured via the FrameworkBundle
(for example UUIDv6 or UUIDv7) is ignored.
When working with DoctrineBundle, prefer using the generator service instead::
#[ORM\Id]
#[ORM\Column(type: 'uuid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator('doctrine.uuid_generator')]
.. warning::