To interface to anything that is expensive or impossible to duplicate.
- Doctrine2 uses proxies to implement framework magic (e.g. lazy initialization) in them, while the user still works with his own entity classes and will never use nor touch the proxies
You can also find this code on GitHub
.. literalinclude:: BankAccount.php :language: php :linenos:
.. literalinclude:: HeavyBankAccount.php :language: php :linenos:
.. literalinclude:: BankAccountProxy.php :language: php :linenos: