Doctrine 2 add single entity
I have a collection of entities in the 'namespace' 'Project'. I have one file called 'Project.php' and at the same directory level I have a folder called 'Project' under which the rest of the 'Project' entities live. I am able to add the entities unde开发者_运维问答r the 'Project' directory to the 'DefaultAnnotationDriver' (by passing it the path to the dir), but I am not able to add Project.php. I cannot add the parent directory as there are other libraries in there that I do not want Doctrine to try to add.
So, in short, how can I add the single entity 'Project.php'?
With the autoloader you can only define a specific namespace to be autoloaded. So if you have a namespace "Project" all files in your Project-directory will be autoloaded if needed. If you want only your Project.php to be loaded automatically, you should put it in a seperate Namespace.
In this case I think, correct me if I'm wrong, it's best to add your project.php file to the Project namespace. Namespaces are generally used to group related classes and seperate them from other classes that are not related. So why put your Project entity outside the namespace if it is related to the ones inside the namespace.
Just my 2 cents.
Good luck!
精彩评论