Introducing a compile step for Metadata #7559

Open
opened 2026-01-22 15:53:25 +01:00 by admin · 0 comments
Owner

Originally created by @beberlei on GitHub (Oct 8, 2025).

Originally assigned to: @mpdude on GitHub.

To improve validation and make metadata use faster and more reliable we want to introduce a compile step for metadata.

For this the ORM would need to have 2 "run modes" similar to Symfony, we introduce a debug mode true/false. This is already publically available in the Setup Tools, but not kept around in configuration for now.

What I think needs to be done (in random order)

  • Introduce a Doctrine command that compiles the metadata cache. In Symfony / DoctrineBundle this should be done with a cache warmer.
  • Remove Configuration::setMetadataCache/getMetadataCache.
  • Remove or not use cache implementation from ClassMetadataFactory (do we need to inline the CMF from persistence?)
  • Compiling the metadata: 1. ClassMetadataFactory::getAllMetadata 2. post validation across all metadata 3. writing them to disk. Use Symfony Var Exporter for this like here: https://gist.github.com/beberlei/2dc2ef300fb252342f0a6dc4a99b1de7
  • Wrap all metadata in a new class ClassMetadatas.
  • Disk format: 1 central file that has key values (entity class => file to require)e, and then each metadata into their own file and another entry with all the mapping files that contributed to the cache including their filemtime.
  • Change EntittyManager::getClassMetadata to look in ClassMetadatas for an entry. If there is no cache built, throw exception, unless debug mode, then generate the complete metadata cache.
  • In Debug mode, check the filemtime of all contributing files for updates.
Originally created by @beberlei on GitHub (Oct 8, 2025). Originally assigned to: @mpdude on GitHub. To improve validation and make metadata use faster and more reliable we want to introduce a compile step for metadata. For this the ORM would need to have 2 "run modes" similar to Symfony, we introduce a debug mode true/false. This is already publically available in the Setup Tools, but not kept around in configuration for now. What I think needs to be done (in random order) * Introduce a Doctrine command that compiles the metadata cache. In Symfony / DoctrineBundle this should be done with a cache warmer. * Remove Configuration::setMetadataCache/getMetadataCache. * Remove or not use cache implementation from ClassMetadataFactory (do we need to inline the CMF from persistence?) * Compiling the metadata: 1. `ClassMetadataFactory::getAllMetadata` 2. post validation across all metadata 3. writing them to disk. Use Symfony Var Exporter for this like here: https://gist.github.com/beberlei/2dc2ef300fb252342f0a6dc4a99b1de7 * Wrap all metadata in a new class `ClassMetadatas`. * Disk format: 1 central file that has key values (entity class => file to require)e, and then each metadata into their own file and another entry with all the mapping files that contributed to the cache including their filemtime. * Change EntittyManager::getClassMetadata to look in `ClassMetadatas` for an entry. If there is no cache built, throw exception, unless debug mode, then generate the complete metadata cache. * In Debug mode, check the filemtime of all contributing files for updates.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7559