I know this is super late, but the answer to the second part of the question regarding auto_generate_proxy_classes
can be found in Doctrine's ORM documentation, here: Auto-Generating Proxy Classes (ORM v2.11 docs).
I recommend also reading the "Proxy Objects" section a little further down on the same page. That section says, in part:
A proxy object is an object that is put in place or used instead of the real object. A proxy object can add behavior to the object being proxied without that object being aware of it. In ORM, proxy objects are used to realize several features but mainly for transparent lazy-loading.
Proxy objects with their lazy-loading facilities help to keep the subset of objects that are already in memory connected to the rest of the objects. This is an essential property as without it there would always be fragile partial objects at the outer edges of your object graph.
Doctrine ORM implements a variant of the proxy pattern where it generates classes that extend your entity classes and adds lazy-loading capabilities to them. Doctrine can then give you an instance of such a proxy class whenever you request an object of the class being proxied.
WARNING: The ORM docs are very clear that this should be allowed in development only. Read more at the link above, but the bottom line is this:
Furthermore you should have the Auto-generating Proxy Classes option to true in development and to false in production. If this option is set to TRUE
it can seriously hurt your script performance if several proxy classes are re-generated during script execution. Filesystem calls of that magnitude can even slower than all the database queries Doctrine issues. Additionally writing a proxy sets an exclusive file lock which can cause serious performance bottlenecks in systems with regular concurrent requests.
tl;dr -- and I know that I'm glossing over a lot of nuances -- this is somewhat like a PHP version of Javascript's Promise model. Don't have an actual object yet? No worries, we'll give you a fake (proxy) one and fill in the details later if you need them. The auto_generate_proxy_classes
setting defines whether or not this is done on the fly at runtime.
For those who want more detailed info on the Proxy Pattern in PHP, try here or here.