On this page

Migration

Migration to Version 3

XmlRpc Client

Version 3 removes the dependency on laminas/laminas-http and replaces it with PSR-18 (HTTP Client), along with PSR-7 (HTTP Messages) and PSR-17 (HTTP Message Factories). This change gives greater flexibility in how HTTP requests are made, but also changes how the XML-RPC client instance is created, and requires that you provide an HTTP client via the constructor.

Previously, the following would create a laminas-http client instance implicitly, and use it for making XML-RPC requests:

$client = new Laminas\XmlRpc\Client('http://time.xmlrpc.com/RPC2');

If you needed to customize the HTTP client, you had the following options:

$httpClient = new Laminas\Http\Client(/* ... */);

// Via constructor injection:
$xmlrpc = new Laminas\XmlRpc\Client('http://time.xmlrpc.com/RPC2', $httpClient);

// Via setter method:
$xmlrpc = new Laminas\XmlRpc\Client('http://time.xmlrpc.com/RPC2');
$xmlrpc->setHttpClient($httpClient);

With version 3, the HTTP client must be a PSR-18 HTTP client implementation, and must be passed to the instance via the constructor, along with a Psr\Http\Message\RequestFactoryInterface instance and a Psr\Http\Message\StreamFactoryInterface instance. The below example uses the php-http/curl-client package to provide the HTTP client, and Laminas Diactoros to provide HTTP message factories:

$xmlrpc = new Laminas\XmlRpc\Client(
    'http://time.xmlrpc.com/RPC2',
    $httpClient,
    $requestFactory,
    $streamFactory
);

Methods Removed

The following methods were removed from Laminas\XmlRpc\Client for version 3.

  • setHttpClient()
  • getHttpClient()

Methods Changed

The following methods are changed in Laminas\XmlRpc\Client for version 3.

  • doRequest() the $response parameter has been removed