[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/ocramius/proxy-manager/html-docs/ -> index.html (source)

   1  <!DOCTYPE html>
   2  <html class="no-js" id="top">
   3  <head>
   4      <title>ProxyManager</title>
   5  
   6      <meta name="description" content="A proxyManager write in php" />
   7      <meta name="keywords" content="ProxyManager, proxy, manager, ocramius, Marco Pivetta, php" />
   8      <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
   9      <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600' rel='stylesheet' type='text/css'>
  10      <link href="css/styles.css" rel="stylesheet" />
  11      <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/default.min.css">
  12      <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script>
  13      <script>hljs.initHighlightingOnLoad();</script>
  14      <link rel="shortcut icon" href="favicon.ico">
  15  </head>
  16  <body>
  17  
  18  <header class="site-header">
  19  <div class="container">
  20  <h1><a href="index.html"><img alt="ProxyManager" src="img/block.png" /></a></h1>
  21  
  22  <nav class="main-nav" role="navigation">
  23  <ul>
  24      <li><a href="https://github.com/Ocramius/ProxyManager" target="_blank">Github</a>
  25      <div class="bcms-clearfix"></div>
  26  </li>
  27  </ul>
  28  </nav>
  29  </div>
  30  </header>
  31  <main role="main">
  32  <section class="component-content"><div class="page-title-wrapper">
  33  <div class="container">
  34      <img src="https://github.com/Ocramius/ProxyManager/raw/master/proxy-manager.png">
  35      <h2 class="page-title">Proxy Manager</h2>
  36  </div>
  37  </div>
  38  
  39  <div class="component-demo" id="live-demo">
  40      <div class="container">
  41              <div class="main-wrapper" style="text-align: right">
  42                  <iframe src="http://ghbtns.com/github-btn.html?user=ocramius&amp;repo=ProxyManager&amp;type=fork&amp;count=true&amp;size=large"
  43    allowtransparency="true" frameborder="0" scrolling="0" width="310" height="40"></iframe>
  44  
  45                  <iframe src="http://ghbtns.com/github-btn.html?user=ocramius&amp;repo=ProxyManager&amp;type=watch&amp;count=true&amp;size=large"
  46    allowtransparency="true" frameborder="0" scrolling="0" width="200" height="40"></iframe>
  47  
  48              </div>
  49          <div class="bcms-clearfix bcms-clearfix"></div>
  50      </div>
  51  </div>
  52  <div class="component-info">
  53  <div class="container">
  54  
  55  <aside class="sidebar">
  56      <nav class="spy-nav">
  57          <ul>
  58              <li><a href="index.html">Intro</a></li>
  59              <li><a href="virtual-proxy.html">Virtual Proxy</a></li>
  60              <li><a href="null-object.html">Null Objects</a></li>
  61              <li><a href="ghost-object.html">Ghost Objects</a></li>
  62              <li><a href="remote-object.html">Remote Object</a></li>
  63              <li><a href="contributing.html">Contributing</a></li>
  64              <li><a href="credits.html">Credits</a></li>
  65              <li><a href="copyright.html">Copyright</a></li>
  66          </ul>
  67      </nav>
  68  <div class="bcms-clearfix bcms-clearfix"></div>
  69  <a class="btn btn-action btn-full download-component"
  70      href="download.html">Download</a>
  71      <div class="bcms-clearfix"></div>
  72  </aside>
  73  
  74  <div class="content">
  75      <h3>Proxy Manager</h3>
  76      <p>This library aims at providing abstraction for generating various kinds of <a href="http://ocramius.github.io/presentations/proxy-pattern-in-php/" target="_blank">proxy classes</a>.</p>
  77      <p>If you want to learn more about proxy pattern watch this video:</p>
  78  
  79      <iframe width="640" height="390" src="//www.youtube.com/embed/Ka8wlV8M6Vg" frameborder="0" allowfullscreen></iframe>
  80  <hr />
  81      <div class="bcms-clearfix"></div>
  82      <h3 class="section-title">Installation</h3>
  83      <p>The suggested installation method is via <a href="https://getcomposer.org/" target="_blank">composer</a>.</p>
  84      <pre><code class="sh">php composer.phar require ocramius/proxy-manager:1.0.*</code></pre>
  85  <hr />
  86  
  87      <h3 class="section-title" id="virtualproxy">Lazy Loading Value Holders (Virtual Proxy)</h3>
  88  
  89      <p>ProxyManager can generate
  90          <a href="http://www.martinfowler.com/eaaCatalog/lazyLoad.html" target="_blank">lazy loading value holders</a>,
  91           which are virtual proxies capable of saving performance and memory for objects that
  92          require a lot of dependencies or CPU cycles to be loaded:
  93          particularly useful when you may not always need the object,
  94          but are constructing it anyways.</p>
  95  
  96      <pre>
  97          <code class="php">
  98  $factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory();
  99  
 100  $proxy = $factory->createProxy(
 101      'MyApp\HeavyComplexObject',
 102      function (&amp; $wrappedObject, $proxy, $method, $parameters, &amp; $initializer) {
 103          $wrappedObject = new HeavyComplexObject(); // instantiation logic here

 104          $initializer   = null; // turning off further lazy initialization

 105  
 106          return true;
 107      }
 108  );
 109  
 110  $proxy->doFoo();
 111          </code>
 112      </pre>
 113  
 114      <p>See the <a href="virtual-proxy.html">complete documentation about lazy loading value holders</a>.</p>
 115  <hr />
 116  
 117      <h3 class="section-title">Access Interceptor Value Holder</h3>
 118  
 119      <p>An access interceptor value holder is a smart reference that allows you to execute
 120       logic before and after a particular method is executed or a particular property is
 121       accessed, and it allows to manipulate parameters and return values depending on
 122       your needs.</p>
 123  
 124      <pre>
 125          <code class="php">
 126  $factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory();
 127  
 128  $proxy = $factory->createProxy(
 129      new \My\Db\Connection(),
 130      array('query' => function () { echo "Query being executed!\n"; }),
 131      array('query' => function () { echo "Query completed!\n"; })
 132  );
 133  
 134  $proxy->query(); // produces "Query being executed!\nQuery completed!\n"

 135          </code>
 136      </pre>
 137  
 138      <p>See the <a href="access-interceptor-value-holder-proxy.html">complete documentation about access interceptor value holders</a>.</p>
 139  <hr />
 140  
 141      <h3 class="section-title">Access Interceptor Scope Localizer</h3>
 142  
 143      <p>An access interceptor scope localizer works exactly like an access interceptor
 144       value holder, but it is safe to use to proxy fluent interfaces.</p>
 145  
 146      <p>See the <a href="access-interceptor-scope-localizer-proxy.html">complete documentation about access interceptor scope localizer</a>.</p>
 147  <hr />
 148  
 149  
 150      <h3 class="section-title">Null Objects</h3>
 151  
 152      <p>A Null Object proxy implements the null object pattern.</p>
 153  
 154      <p>This kind of proxy allows you to have fallback logic in case loading of the wrapped value failed.</p>
 155      <pre>
 156          <code class="php">
 157  $factory = new \ProxyManager\Factory\NullObjectFactory();
 158  
 159  $proxy = $factory->createProxy('My\EntityObject');
 160  
 161  $proxy->getName(); // empty return

 162          </code>
 163      </pre>
 164  
 165      <p>A Null Object Proxy can be created from an object, a class name or an interface name:</p>
 166      <pre>
 167          <code class="php">
 168  $factory = new \ProxyManager\Factory\NullObjectFactory();
 169  
 170  $proxy = $factory->createProxy('My\EntityObjectInterface');
 171  $proxy->getName(); // empty return

 172  
 173  $proxy = $factory->createProxy($entity); // created from object

 174  $proxy->getName(); // empty return

 175          </code>
 176      </pre>
 177  
 178      <p>See the <a href="null-object.html">complete documentation about null object proxy</a>.</p>
 179  
 180  <hr />
 181  
 182      <h3 class="section-title">Ghost Objects</h3>
 183  
 184      <p>Similar to value holder, a ghost object is usually created to handle lazy loading.</p>
 185  
 186      <p>The difference between a value holder and a ghost object is that the ghost
 187          object does not contain a real instance of the required object, but handles
 188          lazy loading by initializing its own inherited properties.</p>
 189  
 190      <p>ProxyManager can generate
 191          <a href="http://www.martinfowler.com/eaaCatalog/lazyLoad.html" target="_blank">lazy loading ghost objects</a>,
 192           which are proxies used to save performance and memory for large datasets and
 193           graphs representing relational data. Ghost objects are particularly useful
 194           when building data-mappers.</p>
 195  
 196      <p>Additionally, the overhead introduced by ghost objects is very low when
 197          compared to the memory and performance overhead caused by virtual proxies.</p>
 198  
 199      <pre>
 200          <code class="php">
 201  $factory = new \ProxyManager\Factory\LazyLoadingGhostFactory();
 202  
 203  $proxy = $factory->createProxy(
 204      'MyApp\HeavyComplexObject',
 205      function ($proxy, $method, $parameters, & $initializer) {
 206          $initializer   = null; // turning off further lazy initialization

 207  
 208          // modify the proxy instance

 209          $proxy->setFoo('foo');
 210          $proxy->setBar('bar');
 211  
 212          return true;
 213      }
 214  );
 215  
 216  $proxy->doFoo();
 217          </code>
 218      </pre>
 219  
 220      <p>See the <a href="ghost-object.html">complete documentation about lazy loading ghost objects</a>.</p>
 221  
 222  <hr />
 223  
 224      <h3 class="section-title">Remote Object</h3>
 225  
 226      <p>A remote object proxy is an object that is located on a different system,
 227          but is used as if it was available locally. There's various possible
 228          remote proxy implementations, which could be based on xmlrpc/jsonrpc/soap/dnode/etc.</p>
 229  
 230      <p>This example uses the XML-RPC client of Zend Framework 2:</p>
 231  
 232      <pre>
 233          <code class="php">
 234  interface FooServiceInterface
 235  {
 236      public function foo();
 237  }
 238  
 239  $factory = new \ProxyManager\Factory\RemoteObjectFactory(
 240      new \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc(
 241          new \Zend\XmlRpc\Client('https://example.com/rpc-endpoint')
 242      )
 243  );
 244  
 245  // proxy is your remote implementation

 246  $proxy = $factory->createProxy('FooServiceInterface');
 247  
 248  var_dump($proxy->foo());
 249          </code>
 250      </pre>
 251  
 252      <p>See the <a href="remote-object.html">complete documentation about remote objects</a>.</p>
 253  <hr />
 254  
 255  
 256  <h3 class="section-title">Contributing</h3>
 257      <p>Please read the <a href="contributing.html">CONTRIBUTING</a> contents if you wish to help out!</p>
 258  
 259  <hr />
 260  
 261  <h3 class="section-title">Credits</h3>
 262  
 263      <p>The idea was originated by a <a href="http://marco-pivetta.com/proxy-pattern-in-php/" target="_blank">talk about Proxies in PHP OOP</a> that I gave at the <a href="https://twitter.com/phpugffm" target="_blank">@phpugffm</a> in January 2013.</p>
 264  
 265  
 266      <div class="bcms-clearfix"></div>
 267  
 268      </div>
 269      </div>
 270  </div>
 271  
 272  
 273  </main>
 274  
 275      <footer class="site-footer" role="contentinfo">
 276          <div class="container">
 277              <div class="footer-logos">
 278                  <ul>
 279                      <li><a href="index.html">Intro</a> | </li>
 280                      <li><a href="virtual-proxy.html">Virtual Proxy</a> | </li>
 281                      <li><a href="null-object.html">Null Objects</a> | </li>
 282                      <li><a href="ghost-object.html">Ghost Objects</a> | </li>
 283                      <li><a href="remote-object.html">Remote Object</a> | </li>
 284                      <li><a href="contributing.html">Contributing</a> | </li>
 285                      <li><a href="credits.html">Credits</a> | </li>
 286                      <li><a href="copyright.html">Copyright</a></li>
 287                  </ul>
 288              </div>
 289          </div>
 290  
 291          <div class="bcms-clearfix"></div>
 292      </footer>
 293      <div class="bcms-clearfix"></div>
 294      </body>
 295  </html>


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1