204 lines
6.8 KiB
HTML
204 lines
6.8 KiB
HTML
<!DOCTYPE html>
|
|
<html class="no-js" id="top">
|
|
<head>
|
|
<title>ProxyManager - Remote object</title>
|
|
|
|
<meta name="description" content="A proxyManager write in php" />
|
|
<meta name="keywords" content="ProxyManager, proxy, manager, ocramius, Marco Pivetta, php, remote object" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
|
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600' rel='stylesheet' type='text/css'>
|
|
<link href="css/styles.css" rel="stylesheet" />
|
|
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/default.min.css">
|
|
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script>
|
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
<link rel="shortcut icon" href="favicon.ico">
|
|
</head>
|
|
<body>
|
|
|
|
<header class="site-header">
|
|
<div class="container">
|
|
<h1><a href="index.html"><img alt="ProxyManager" src="img/block.png" /></a></h1>
|
|
|
|
<nav class="main-nav" role="navigation">
|
|
<ul>
|
|
<li><a href="https://github.com/Ocramius/ProxyManager" target="_blank">Github</a>
|
|
<div class="bcms-clearfix"></div>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</header>
|
|
<main role="main">
|
|
<section class="component-content">
|
|
|
|
<div class="component-demo" id="live-demo">
|
|
<div class="container">
|
|
<div class="main-wrapper" style="text-align: right">
|
|
<iframe src="http://ghbtns.com/github-btn.html?user=ocramius&repo=ProxyManager&type=fork&count=true&size=large"
|
|
allowtransparency="true" frameborder="0" scrolling="0" width="310" height="40"></iframe>
|
|
|
|
<iframe src="http://ghbtns.com/github-btn.html?user=ocramius&repo=ProxyManager&type=watch&count=true&size=large"
|
|
allowtransparency="true" frameborder="0" scrolling="0" width="200" height="40"></iframe>
|
|
|
|
</div>
|
|
<div class="bcms-clearfix bcms-clearfix"></div>
|
|
</div>
|
|
</div>
|
|
<div class="component-info">
|
|
<div class="container">
|
|
<aside class="sidebar">
|
|
<nav class="spy-nav">
|
|
<ul>
|
|
<li><a href="index.html">Intro</a></li>
|
|
<li><a href="virtual-proxy.html">Virtual Proxy</a></li>
|
|
<li><a href="null-object.html">Null Objects</a></li>
|
|
<li><a href="ghost-object.html">Ghost Objects</a></li>
|
|
<li><a href="remote-object.html">Remote Object</a></li>
|
|
<li><a href="contributing.html">Contributing</a></li>
|
|
<li><a href="credits.html">Credits</a></li>
|
|
<li><a href="copyright.html">Copyright</a></li>
|
|
</ul>
|
|
</nav>
|
|
<div class="bcms-clearfix bcms-clearfix"></div>
|
|
<a class="btn btn-action btn-full download-component"
|
|
href="download.html">Download</a>
|
|
<div class="bcms-clearfix"></div>
|
|
</aside>
|
|
|
|
<div class="content">
|
|
<div class="bcms-clearfix"></div>
|
|
<h3 class="section-title">Remote Object Proxy</h3>
|
|
|
|
<p>The remote object implementation is a mechanism that enables an local object to control an other object on an other server. Each call method on the local object will do a network call to get information or execute operations on the remote object.</p>
|
|
<hr />
|
|
|
|
<h3 class="section-title">What is remote object proxy ?</h3>
|
|
|
|
<p>A remote object is based on an interface. The remote interface defines the API that a consumer can call. This interface must be implemented both by the client and the RPC server.</p>
|
|
<hr />
|
|
|
|
<h3 class="section-title">Adapters</h3>
|
|
|
|
<p>ZendFramework's RPC components (XmlRpc, JsonRpc & Soap) can be used easily with the remote object. You will need to require the one you need via composer, though:</p>
|
|
|
|
<pre>
|
|
<code class="sh">
|
|
$ php composer.phar require zendframework/zend-xmlrpc:2.*
|
|
$ php composer.phar require zendframework/zend-json:2.*
|
|
$ php composer.phar require zendframework/zend-soap:2.*
|
|
</code>
|
|
</pre>
|
|
|
|
<p>ProxyManager comes with 3 adapters:</p>
|
|
|
|
<ul>
|
|
<li><code>ProxyManager\Factory\RemoteObject\Adapter\XmlRpc</code></li>
|
|
<li><code>ProxyManager\Factory\RemoteObject\Adapter\JsonRpc</code></li>
|
|
<li><code>ProxyManager\Factory\RemoteObject\Adapter\Soap</code></li>
|
|
</ul>
|
|
|
|
<hr />
|
|
|
|
<h3 class="section-title">Usage examples</h3>
|
|
|
|
<p>RPC server side code (<code>xmlrpc.php</code> in your local webroot):</p>
|
|
|
|
<pre>
|
|
<code class="php">
|
|
interface FooServiceInterface
|
|
{
|
|
public function foo();
|
|
}
|
|
|
|
class Foo implements FooServiceInterface
|
|
{
|
|
/**
|
|
* Foo function
|
|
* @return string
|
|
*/
|
|
public function foo()
|
|
{
|
|
return 'bar remote';
|
|
}
|
|
}
|
|
|
|
$server = new Zend\XmlRpc\Server();
|
|
$server->setClass('Foo', 'FooServiceInterface'); // my FooServiceInterface implementation
|
|
$server->handle();
|
|
</code>
|
|
</pre>
|
|
|
|
<p>Client side code (proxy) :</p>
|
|
|
|
<pre>
|
|
<code class="php">
|
|
interface FooServiceInterface
|
|
{
|
|
public function foo();
|
|
}
|
|
|
|
$factory = new \ProxyManager\Factory\RemoteObjectFactory(
|
|
new \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc(
|
|
new \Zend\XmlRpc\Client('https://localhost/xmlrpc.php')
|
|
)
|
|
);
|
|
|
|
$proxy = $factory->createProxy('FooServiceInterface');
|
|
|
|
var_dump($proxy->foo()); // "bar remote"
|
|
</code>
|
|
</pre>
|
|
<hr />
|
|
|
|
<h3 class="section-title">Implementing custom adapters</h3>
|
|
|
|
<p>Your adapters must implement <code>ProxyManager\Factory\RemoteObject\AdapterInterface</code> :</p>
|
|
|
|
<pre>
|
|
<code class="php">
|
|
interface AdapterInterface
|
|
{
|
|
/**
|
|
* Call remote object
|
|
*
|
|
* @param string $wrappedClass
|
|
* @param string $method
|
|
* @param array $params
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function call($wrappedClass, $method, array $params = array());
|
|
}
|
|
</code>
|
|
</pre>
|
|
|
|
<p>It is very easy to create your own implementation (for RESTful web services, for example). Simply pass your own adapter instance to your factory at construction time</p>
|
|
|
|
<p>Tuning performance for production</p>
|
|
|
|
<p>See <a href="production.html">Tuning ProxyManager for Production.</a></p>
|
|
|
|
</main>
|
|
|
|
<footer class="site-footer" role="contentinfo">
|
|
<div class="container">
|
|
<div class="footer-logos">
|
|
<ul>
|
|
<li><a href="index.html">Intro</a> | </li>
|
|
<li><a href="virtual-proxy.html">Virtual Proxy</a> | </li>
|
|
<li><a href="null-object.html">Null Objects</a> | </li>
|
|
<li><a href="ghost-object.html">Ghost Objects</a> | </li>
|
|
<li><a href="remote-object.html">Remote Object</a> | </li>
|
|
<li><a href="contributing.html">Contributing</a> | </li>
|
|
<li><a href="credits.html">Credits</a> | </li>
|
|
<li><a href="copyright.html">Copyright</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bcms-clearfix"></div>
|
|
</footer>
|
|
<div class="bcms-clearfix"></div>
|
|
</body>
|
|
</html>
|