17 Nov 2010

Doctrine - Versionable behavior configuration for use in symfony

If you use doctrine's Versionable behavior you might notice some performance issues, especially if you use a large number of models. The behavior generates a second model for each model. This second model represents the history log. It happens on demand and in memory for each request. The lazy generation can be turned off by option generateFiles: true. The generated model is then written to the location specified by generatePath.

Everything is fine except you're using symfony. The generated models are not extended from sfDoctrineRecord and written to another directory because of the default configuration of Doctrine_Import_Builder inside of Doctrine_AuditLog. It took me a while to figure out how to configure doctrine's Versionable behavior for symfony's directory structure.

Here is the result: