Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

remote-object.md

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 2.58 KiB


 001  # Remote Object Proxy
 002   
 003  The remote object implementation is a mechanism that enables an local object to control an other object on an other server.
 004  Each call method on the local object will do a network call to get information or execute operations on the remote object.
 005   
 006  ## What is remote object proxy ?
 007   
 008  A remote object is based on an interface. The remote interface defines the API that a consumer can call. This interface 
 009  must be implemented both by the client and the RPC server.
 010   
 011  ## Adapters
 012   
 013  ZendFramework's RPC components (XmlRpc, JsonRpc & Soap) can be used easily with the remote object.
 014  You will need to require the one you need via composer, though:
 015   
 016  ```sh
 017  $ php composer.phar require zendframework/zend-xmlrpc:2.*
 018  $ php composer.phar require zendframework/zend-json:2.*
 019  $ php composer.phar require zendframework/zend-soap:2.*
 020  ```
 021   
 022  ProxyManager comes with 3 adapters:
 023   
 024   * `ProxyManager\Factory\RemoteObject\Adapter\XmlRpc`
 025   * `ProxyManager\Factory\RemoteObject\Adapter\JsonRpc`
 026   * `ProxyManager\Factory\RemoteObject\Adapter\Soap`
 027   
 028  ## Usage examples
 029   
 030  RPC server side code (`xmlrpc.php` in your local webroot):
 031   
 032  ```php
 033  interface FooServiceInterface
 034  {
 035      public function foo();
 036  }
 037   
 038  class Foo implements FooServiceInterface
 039  {
 040      /**
 041       * Foo function
 042       * @return string
 043       */
 044      public function foo()
 045      {
 046          return 'bar remote';
 047      }
 048  }
 049   
 050  $server = new Zend\XmlRpc\Server();
 051  $server->setClass('Foo', 'FooServiceInterface');  // my FooServiceInterface implementation
 052  $server->handle();
 053  ```
 054   
 055  Client side code (proxy) :
 056   
 057  ```php
 058   
 059  interface FooServiceInterface
 060  {
 061      public function foo();
 062  }
 063   
 064  $factory = new \ProxyManager\Factory\RemoteObjectFactory(
 065      new \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc(
 066          new \Zend\XmlRpc\Client('https://localhost/xmlrpc.php')
 067      )
 068  );
 069   
 070  $proxy = $factory->createProxy('FooServiceInterface');
 071   
 072  var_dump($proxy->foo()); // "bar remote"
 073  ```
 074   
 075  ## Implementing custom adapters
 076   
 077  Your adapters must implement `ProxyManager\Factory\RemoteObject\AdapterInterface` :
 078   
 079  ```php
 080  interface AdapterInterface
 081  {
 082      /**
 083       * Call remote object
 084       *
 085       * @param string $wrappedClass
 086       * @param string $method
 087       * @param array $params
 088       *
 089       * @return mixed
 090       */
 091      public function call($wrappedClass, $method, array $params = array());
 092  }
 093  ```
 094   
 095  It is very easy to create your own implementation (for RESTful web services, for example). Simply pass
 096  your own adapter instance to your factory at construction time
 097   
 098  ## Tuning performance for production
 099   
 100  See [Tuning ProxyManager for Production](https://github.com/Ocramius/ProxyManager/blob/master/docs/tuning-for-production.md).
 101