Skip to content

Files

Latest commit

author
Dominik Liebler
Jun 14, 2018
0f4da34 · Jun 14, 2018

History

History
This branch is 394 commits behind DesignPatternsPHP/DesignPatternsPHP:main.

Proxy

Purpose

To interface to anything that is expensive or impossible to duplicate.

Examples

  • 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

UML Diagram

Alt Proxy UML Diagram

Code

You can also find this code on GitHub

BankAccount.php

.. literalinclude:: BankAccount.php
   :language: php
   :linenos:

HeavyBankAccount.php

.. literalinclude:: HeavyBankAccount.php
   :language: php
   :linenos:

BankAccountProxy.php

.. literalinclude:: BankAccountProxy.php
   :language: php
   :linenos:

Test