ReflectionException is thrown when mapping entities in Doctrine from different databases

前提是你 提交于 2019-12-01 14:13:56

I managed to fix it. In my Server\Entity\Server, I had these getter/setter functions for adding/removing websites:

public function setWebsite(Website $website) 
{
   $this->websites->add($website);    
}

public function removeWebsite(Website $website)
{
   $this->websites->removeElement($website);
}

But you need to specify the full namespace as the argument:

public function setWebsite(\Client\Entity\Website $website) { ... }

Such a stupid mistake! I found the issue because I trawled through every file in the stack-trace and got to the point where it was attempting to save every method/argument in my Entity class to a proxy file (line 223ish in Doctrine/ORM/Proxy/ProxyFactory.php).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!