Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A modern, super fast XML/RPC client for PHP >=5.4

Merge pull request #39 from sagikazarmark/patch-1

Updates PHP version requirement
latest commit 376f954655
@lstrojny authored

fxmlrpc: really fast XML/RPC for PHP

Gitter Build Status Dependency Status Average time to resolve an issue Percentage of issues still open

  • A convenient, object oriented API (similar to the XML/RPC client in Zend Framework)
  • Very fast serializing and parsing of the XML payloads involved
  • Stick to the HTTP client you already use provided by Ivory Http Adapter
  • Licensed under the terms of the liberal MIT license
  • Supports modern standards: easy installation via composer, fully PSR-0, PSR-1 and PSR-2 compatible
  • Relentlessly unit- and integration tested
  • Implements all known XML/RPC extensions

Latest improvements

  • [BC] PSR-4 for autoloading (see #29)
  • [BC] Rename fXmlRpc\Multicall to fXmlRpc\MulticallBuilder
  • [BC] Make the surface of the ClientInterface signifcantly smaller (see #24 for details)
  • [BC] Replaces built-in transports with Ivory HTTP Adapter. PECL HTTP is no longer supported. Contribution by Márk Sági-Kazár
  • [BUG] Fix serialization issue with XmlWriterSerializer (see #19 for details)
  • [FEATURE] New bridge for artax (with contributions by Markus Staab)
  • [FEATURE] New bridge for Guzzle 4 (contribution by Robin van der Vleuten)
  • [FEATURE] Allow HTTP transport headers to be controlled
  • [FEATURE] Allow transport content type and charset to be controlled (see #9)
  • [BC] Removing outdated PeclHttpBridge
  • [BC] Requiring PHP 5.4
  • [BUG] Fixing huge issue in XmlWriterSerializer (see #4 for details)
  • [FEATURE] Special API for multicall
  • [FEATURE] Supports all Java XML/RPC extensions
  • [BC] fXmlRpc\AbstractDecorator and fXmlRpc\ClientInterface now includes methods to prepend and append parameters
  • [BC] fXmlRpc\Client is marked as final. Properties marked as private. Extend via decorator.
  • [BC] Marked deprecated constructor of fXmlRpc\Value\Base64 as private. Additionally, the value object is final now
  • [TESTING] Integration test suite against Java XML/RPC and Python XML/RPC
  • [BUG] Fixing implicit string type handling (where string is no child of value)
  • [IMPROVEMENT] Improved exception handling
  • [BC] Changing naming scheme to studly caps
  • [BUG] Fixing various array/struct edge cases
  • [IMPROVEMENT] Small memory and performance improvements for serializers and parsers
  • [BC] Deprecated constructor of fXmlRpc\Value\Base64 and introduced ::serialize() an ::deserialize() instead.
  • [FEATURE] Adding fXmlRpc\Client::prependParams() and fXmlRpc\Client::appendParams() to set default params. This helps e.g. when you need to add authorization information for every call
  • [FEATURE] Timing Loggers now support threshold based logging to ease controlling your servers responds in a certain time
  • [TESTING] Travis now runs the test suite against various versions of supported HTTP clients and logging components.

How fast is it really?

IO performance is out of reach from a userspace perspective, but parsing and serialization speed is what matters. How fast can we generate the XML payload from PHP data structures and how fast can we parse the servers response? fXmlRpc uses stream based XML writers/readers to achieve it’s performance and heavily optimizes (read uglifies) for it. As as result the userland version is only around 2x slower than the native C implementation (ext/xmlrpc).


Zend\XmlRpc\Value (ZF2): 249.02972793579 sec
Zend_XmlRpc_Value (ZF1): 253.88145494461 sec
fXmlRpc\Parser\XmlReaderParser: 36.274516105652 sec
fXmlRpc\Parser\NativeParser: 18.652323007584 sec


Zend\XmlRpc\Request (ZF2): 52.004573106766 sec
Zend_XmlRpc_Request (ZF1): 65.042532920837 sec
fXmlRpc\Serializer\XmlWriterSerializer: 23.652673006058 sec
fXmlRpc\Serializer\NativeSerializer: 9.0790779590607 sec


Basic Usage

$client = new fXmlRpc\Client('');
$client->call('remoteMethod', array('arg1', true));

Using native (ext/xmlrpc based) serializer/parser (for even better performance)

$client = new fXmlRpc\Client(
    new fXmlRpc\Parser\NativeParser(),
    new fXmlRpc\Serializer\NativeSerializer()
$client->call('remoteMethod', array('arg1', true));

Prepending and appending arguments

$client = new fXmlRpc\Client('');
$client->prependParams(array('username', 'password'));

Using a convenient Proxy object

$proxy = new fXmlRpc\Proxy(new fXmlRpc\Client(''));
// Call system.echo
$proxy->system->echo('Hello World!');

Helpful abstraction for multicall requests

$result = $client->multicall()
    ->addCall('system.add', array(1, 2))
        array(2, 3),
        function ($result) {
            echo "Result was: " . $result;
        function($result) {
            echo "An error occured: " . var_export($result, true);
    ->onSuccess(function ($result) {echo "Success";}) // Success handler for each call
    ->onError(function ($result) {echo "Error";}) // Error handler for each call

Integration for various HTTP clients using Ivory

/** Buzz ( */
$browser = new Buzz\Browser();
$client = new fXmlRpc\Client(
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\BuzzHttpAdapter($browser))

/** Zend Framework 1 ( */
$httpClient = new Zend_Http_Client();
$client = new fXmlRpc\Client(
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\Zend1HttpAdapter($httpClient))

/** Zend Framework 2 ( */
$httpClient = new Zend\Http\Client();
$client = new fXmlRpc\Client(
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\Zend2HttpAdapter($httpClient))

/** Guzzle ( */
$httpClient = new Guzzle\Http\Client();
$client = new fXmlRpc\Client(
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\GuzzleAdapter($httpClient))

/** Guzzle 4+ ( */
$httpClient = new GuzzleHttp\Client();
$client = new fXmlRpc\Client(
    new fXmlRpc\Transport\HttpAdapterTransport(new \Ivory\HttpAdapter\GuzzleHttpAdapter($httpClient))

Timing XML/RPC requests to find problematic calls

fXmlRpc allows you to time your XML/RPC request, to find out which took how long. It provides a fXmlRpc\Timing\TimingDecorator which can be used with various timers implementing fXmlRpc\Timing\TimerInterface. Currently implemented are bridges for Monolog, Zend Framework 1 Zend_Log and Zend Framework 2 Zend\Log.


$client = new fXmlRpc\Timing\TimingDecorator(
    new fXmlRpc\Client(...),
    new fXmlRpc\Timing\MonologTimerBridge(
        'My custom log message template %F'
Something went wrong with that request. Please try again.