I'm using Doctrine as ORM in my project but ran against a strange error:
Using following YAML:
Album:
tableName: dpp_album
actAs: [Timestampable]
columns:
name: string(255)
description: string(255)
online: boolean
I then generate my models but upon refreshing my page and autoloading the models, PHP serves this error:
Fatal error: Class 'BaseAlbum' not found in E:\sites\dpp\system\application\models\Album.php on line 13
Strangely enough all my other models are just fine and the Base Classes are found in those cases.
When changing the name 'Album' to something like 'Set' it just works! Ain't that strange?!
So it seems the using 'Album' somehow conflicts, although the error message suggests something else. Change to the plural Albums also doesn't work, anything else is just fine!
Any suggestions?
Thanks!
The problem lies in the autoloading order of the model classes.
Generated 'Base' models live under the 'models/generated' directory and the other ones in the directory above.
Loading order can't be assured, so sometimes a model gets loaded before the Base model upon which it extends and thus throwing this error.
In my bootstrap file, I have now explicitly included the loading order of the directories as following:
The documentation uses a lot of examples resulting in generated files but does not mention this behavior when talking about bootstrap configurations.
Anyway, happy this is fixed now! :-)
If the option generateBaseClasses is set (default) generateModelsFromYaml() will in your case create a class
AlbumBase
(by default in the subdirectorygenerated
) and an empty classAlbum extends AlbumBase
. I.e. ifAlbum
is instantiatedAlbumBase
must already been known or loaded by some autoloader.