laminas/laminas-xmlrpc
Laminas XML-RPC provides client and server components for XML-RPC in PHP. Build and parse XML-RPC requests/responses, expose methods via a server, and integrate with Laminas components for transport, encoding, and fault handling.
From its home page, XML-RPC is described as:
"...remote procedure calling using HTTP as the transport and XML as the encoding. XML-RPC is designed to be as simple as possible, while allowing complex data structures to be transmitted, processed and returned."
laminas-xmlrpc provides support for both consuming remote XML-RPC services and providing XML-RPC servers.
The following demonstrates the most basic use case for Laminas\XmlRpc\Server:
class Greeter
{
/**
* Say hello to someone.
*
* [@param](https://github.com/param) string $name Who to greet
* [@return](https://github.com/return) string
*/
public function sayHello($name = 'Stranger')
{
return sprintf("Hello %s!", $name);
}
}
$server = new Laminas\XmlRpc\Server;
// Our Greeter class will be called "greeter" from the client:
$server->setClass('Greeter', 'greeter');
$server->handle();
Docblock annotations are required
Function and method docblocks containing parameter and return value annotations are required when exposing them via
Laminas\XmlRpc\Server. The values will be used to validate method parameters and provide method signatures to clients.Docblock descriptions will also be used to provide method help text.
The following demonstrates an XML-RPC client that can consume the above service:
$client = new Laminas\XmlRpc\Client('http://example.com/xmlrpcserver.php');
echo $client->call('greeter.sayHello');
// will output "Hello Stranger!"
echo $client->call('greeter.sayHello', ['Dude']);
// will output "Hello Dude!"
How can I help you explore Laravel packages today?