Why does Doctrine\\ORM\\Configuration's “DoctrineProxies” Object contain the Universe?

☆樱花仙子☆ 提交于 2019-12-02 12:20:13

You can't dump a proxy object without XDebug or similar tools (which limit the dumped object size).

The problem is really, really simple:

Proxy -> references EntityManager -> references UnitOfWork -> contains Proxy

This obviously leads to a recursive data-structure dump, which in turn leads to a mess any time you try to dump it without sensible limits.

DoctrineProxies\__CG__\Application\Entity\Product is a proxy class... which means that doctrine doesn't actually fetch the entity from the database (for performance) unless it is needed (i.e. calling $product->getName() those proxy Classes are in a recursive loop with eachother and are VERY large as you saw... most of the information there you don't really need unless you are diving deep ... you should never use print_r ... in the new symfony 2.7+ i think there is a function called dump() in debug mode ... if you use that to print the entity it has loop protection and it just shows reference numbers ... you can also use the \Doctrine\Common\Util\Debug::dump() that also will print out a smaller list than 2^234234234 lines ...

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