PHPackages                             lstrojny/fxmlrpc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. lstrojny/fxmlrpc

ActiveLibrary[API Development](/categories/api)

lstrojny/fxmlrpc
================

Fast and tiny XML/RPC client with bridges for various HTTP clients

0.22.0(4y ago)1425.4M↓13.9%43[7 issues](https://github.com/lstrojny/fxmlrpc/issues)[1 PRs](https://github.com/lstrojny/fxmlrpc/pulls)20MITPHPPHP ^7.2 || ^8.0CI failing

Since Dec 3Pushed 4mo ago6 watchersCompare

[ Source](https://github.com/lstrojny/fxmlrpc)[ Packagist](https://packagist.org/packages/lstrojny/fxmlrpc)[ RSS](/packages/lstrojny-fxmlrpc/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (14)Versions (33)Used By (20)

fxmlrpc: really fast XML/RPC for PHP
====================================

[](#fxmlrpc-really-fast-xmlrpc-for-php)

[![Gitter](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/lstrojny/fxmlrpc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[![Build Status](https://camo.githubusercontent.com/74a510998792797cab19449e33318cedfb8a80fc7bcac92e447dca163c28ae87/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6c7374726f6a6e792f66786d6c7270632e737667)](http://travis-ci.org/lstrojny/fxmlrpc) [![Average time to resolve an issue](https://camo.githubusercontent.com/f025d9bc94b0c2fc2e11b8e643de5a51ef0d2bbee1ebe66fe0504e192b0485ed/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f7265736f6c7574696f6e2f6c7374726f6a6e792f66786d6c7270632e737667)](http://isitmaintained.com/project/lstrojny/fxmlrpc "Average time to resolve an issue") [![Percentage of issues still open](https://camo.githubusercontent.com/848ddcaa7b39e56a35a60ffd1bb9f8dbb267b86d10b2107fbeb382e1e8bd9c88/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f6f70656e2f6c7374726f6a6e792f66786d6c7270632e737667)](http://isitmaintained.com/project/lstrojny/fxmlrpc "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 [HTTPlug](http://httplug.io/)
- 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

Upgrading to 0.23.x
-------------------

[](#upgrading-to-023x)

Instead of `php-http/message-factory`, we now use the PSR-7 compatible `RequestFactoryInterface`. You will have to change your custom HTTP client implementation and pass a `Psr\Http\Message\RequestFactoryInterface` implementation, a `Psr\Http\Message\StreamFactoryInterface` and a `Http\Client\HttpClient` to the `HttpAdapterTransport`. See below for details.

Installation
------------

[](#installation)

To install fxmlrpc run this command:

```
composer require lstrojny/fxmlrpc

```

### Install dependencies

[](#install-dependencies)

You must choose three packages for for the business of HTTP:

- A PSR-7 compatible HTTP message (request / response) implementation
- A compatible HTTP RequestFactoryInterface and StreamFactoryInterface implementations to create HTTP messages
- A PSR-7 compatible HTTP client Two widespread message implementations are [laminas/laminas-diactoros](https://github.com/laminas/laminas-diactoros) and [guzzle/psr7](https://github.com/guzzle/psr7). Message factories for both implementations are available in [php-http/message](https://github.com/php-http/message). For HTTP clients you can pick e.g.[php-http/guzzle7-adapter](https://github.com/php-http/guzzle7-adapter), [php-http/guzzle6-adapter](https://github.com/php-http/guzzle6-adapter), [php-http/guzzle5-adapter](https://github.com/php-http/guzzle5-adapter), [php-http/curl-client](https://github.com/php-http/curl-client) or [php-http/buzz-adapter](https://github.com/php-http/buzz-adapter).

Example:

```
composer require php-http/message php-http/guzzle7-adapter

```

### Instantiating `HttpAdapterTransport`

[](#instantiating-httpadaptertransport)

An example instantiation using Guzzle6:

```
$httpClient = new GuzzleHttp\Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(
        new \Http\Message\MessageFactory\DiactorosMessageFactory(),
        new \Http\Message\StreamFactory\DiactorosStreamFactory(),
        new \Http\Adapter\Guzzle7\Client($httpClient)
    )
);
```

Upgrading to 0.12.x
-------------------

[](#upgrading-to-012x)

Instead of `egeloen/http-adapter`, we now use the PSR-7 compatible `php-http/httplug`. You will have to change your custom HTTP client implementation and pass a `Http\Message\MessageFactory` implementation and a `Http\Client\HttpClient` to the `HttpAdapterTransport`. See below for details.

Installation
------------

[](#installation-1)

To install fxmlrpc run this command:

```
composer require lstrojny/fxmlrpc

```

### Install dependencies

[](#install-dependencies-1)

You must choose three packages for for the business of HTTP:

- A PSR-7 compatible HTTP message (request / response) implementation
- A compatible HTTP message factory implementation to create HTTP messages
- A PSR-7 compatible HTTP client Two widespread message implementations are [zend-diactoros](https://github.com/zendframework/zend-diactoros) and [guzzle/psr7](https://github.com/guzzle/psr7). Message factories for both implementations are available in [php-http/message](https://github.com/php-http/message). For HTTP clients you can pick e.g. [php-http/guzzle6-adapter](https://github.com/php-http/guzzle6-adapter), [php-http/guzzle5-adapter](https://github.com/php-http/guzzle5-adapter), [php-http/curl-client](https://github.com/php-http/curl-client) or [php-http/buzz-adapter](https://github.com/php-http/buzz-adapter).

Example:

```
composer require zendframework/zend-diactoros php-http/message php-http/guzzle6-adapter

```

### Instantiating `HttpAdapterTransport`

[](#instantiating-httpadaptertransport-1)

An example instantiation using Guzzle6:

```
$httpClient = new GuzzleHttp\Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(
        new \Http\Message\MessageFactory\DiactorosMessageFactory(),
        new \Http\Adapter\Guzzle6\Client($httpClient)
    )
);
```

Upgrading to 0.11.x
-------------------

[](#upgrading-to-011x)

We change `ParserInterface::parse()` method interface, now isn't required to pass second parameter ($isFault), parser should throw an exception FaultException when fault message is encountered in server response.

Upgrading to 0.10.x
-------------------

[](#upgrading-to-010x)

0.10.x comes with a couple of breaking changes: We used to ship our own bridges for interoperability with various HTTP clients but moved that responsibility to a 3rd party library called [Ivory HTTP Adapter](https://github.com/egeloen/ivory-http-adapter). *IMPORTANT NOTE:* the library is not installed by default as you could choose to use fxmlrpc with just your own implementation of the `fXmlRpc\Transport\TransportInterface`. To install the library – and that’s what you most likely want – add this line to your `composer.json`

```
"egeloen/http-adapter": "~0.6"

```

… and run `composer update`

### Instantiating an HTTP transport

[](#instantiating-an-http-transport)

In order to use the new adapters, you need to change how you instantiate fXmlRpc and its transport. This is how instantiating a custom transport looked before:

```
$httpClient = new GuzzleHttp\Client();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\Guzzle4Bridge($httpClient)
);
```

This is how you do it now:

```
$httpClient = new GuzzleHttp\Client();
$httpClient->...();
$client = new fXmlRpc\Client(
    'http://endpoint.com',
    new fXmlRpc\Transport\HttpAdapterTransport(new Ivory\HttpAdapter\GuzzleHttpHttpAdapter($httpClient))
);
```

Latest improvements
-------------------

[](#latest-improvements)

- `[BC]` PSR-7 support
- `[IMPROVEMENT]` PHP7 compatibility
- `[IMPROVEMENT]` Refactor parsers throw fault exception instead of client (see #53, contribution by [Piotr Olaszewski](https://github.com/piotrooo))
- `[FEATURE]` Add XML validation on the client side. Configurable but enabled per default
- `[FEATURE]` Transport decorator which contains XML of the last request, response and exception (see #47, contribution by [Piotr Olaszewski](https://github.com/piotrooo))
- `[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](https://github.com/egeloen/ivory-http-adapter). PECL HTTP is no longer supported. Contribution by [Márk Sági-Kazár](https://github.com/sagikazarmark)
- `[BUG]` Fix serialization issue with XmlWriterSerializer (see #19 for details)
- `[FEATURE]` New bridge for [artax](https://github.com/amphp/artax) (with contributions by [Markus Staab](https://github.com/staabm))
- `[FEATURE]` New bridge for Guzzle 4 (contribution by [Robin van der Vleuten](https://github.com/RobinvdVleuten))
- `[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?

[](#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).

#### Parser

[](#parser)

```
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

```

#### Serializer

[](#serializer)

```
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

```

### Usage

[](#usage)

#### Basic Usage

[](#basic-usage)

```
