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