PHPackages                             milo/xml-rpc - 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. milo/xml-rpc

ActiveLibrary[API Development](/categories/api)

milo/xml-rpc
============

Lightweight XML-RPC library.

v3.0.0(6y ago)8220.7k↓37.6%4[1 issues](https://github.com/milo/xml-rpc/issues)1BSD-3-ClausePHPPHP &gt;=7.1

Since Feb 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/milo/xml-rpc)[ Packagist](https://packagist.org/packages/milo/xml-rpc)[ RSS](/packages/milo-xml-rpc/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (1)

XML-RPC
=======

[](#xml-rpc)

This library helps to work with XML-RPC calls and responses. It requires only PHP DOM extension. It is based on word written specification on .

PHP 7.1 or newer is required since v3.0 release. The v2.x releases supports PHP 5.4.

Simple XML-RPC client and server examples follow.

Client
======

[](#client)

```
require 'src/xml-rpc.php';

use Milo\XmlRpc;

# Converter between XML source and PHP classes
$converter = new XmlRpc\Converter;

# Method we are calling and its arguments
$call = new XmlRpc\MethodCall('math.power', [2, 3]);

# Perform request over HTTP
$context = stream_context_create([
	'http' => array(
		'method' => 'POST',
		'header' => 'Content-type: text/xml',
		'content' => $converter->toXml($call),
	),
]);
$xml = file_get_contents('http://example.com', false, $context);

# XML response parsing
$response = $converter->fromXml($xml);
if (!$response instanceof XmlRpc\MethodResponse) {
	throw new Exception('Expected method response. Got ' . get_class($response));
}

# Returned value
var_dump($response->getReturnValue());
```

Server - manually
=================

[](#server---manually)

An example of `echo` server. It only returns array with method name and its arguments which we called.

```
require 'src/xml-rpc.php';

use Milo\XmlRpc;

# Converter between XML source and PHP classes
$converter = new XmlRpc\Converter;

# Incoming XML
$xml = file_get_contents('php://input');

try {
	$call = $converter->fromXml($xml);
	if (!$call instanceof XmlRpc\MethodCall) {
		throw new Exception('Expected method call. Got ' . get_class($call));
	}

	# Echo response
	$response = new XmlRpc\MethodResponse([
		'youCalled' => $call->getName(),
		'withParameters' => $call->getParameters(),
	]);

} catch (XmlRpc\RuntimeException $e) {
	# Fault response on error
	$response = XmlRpc\MethodFaultResponse::fromException($e);
}

# Print XML on standard output
echo $converter->toXml($response);
```

Server - automatically
======================

[](#server---automatically)

An example of methods handling more automatically than above.

```
require 'src/xml-rpc.php';

use Milo\XmlRpc;

# Incoming XML
$xml = file_get_contents('php://input');

# Method call handler server
$server = new XmlRpc\Server;
$server->registerHandler(
	'my.method', ['string', 'int', '2?' => 'bool|null'],
	function ($string, $int, $bool = null) {
		# Throw XmlRpc\FaultResponseException and client will get your error message and code.
		# Throw anything else and client will get fault response with code 500.
		return [...];
	}
);

# Handle XML directly. All exceptions are caught and converted to fault response.
echo $server->handleXml($xml, $faultCode);  # $faultCode is filled by fault response code

# Or handle MethodCall object.
$converter = new XmlRpc\Converter;

# It may throw exception on invalid XML.
$call = $converter->fromXml($xml);

# All exceptions are caught and converted to fault response.
$response = $server->handle($call);

# Print XML on standard output
echo $converter->toXml($response);

# To log what's happening inside.
$server->addLogger(function (MethodCall $call = null, IMethodResponse $response = null, \Exception $e = null) {
	...
});
```

Installation
============

[](#installation)

By [Composer](https://getcomposer.org/) `composer require milo/xml-rpc` or download manually and `require 'src/xml-rpc.php';`

License
=======

[](#license)

You may use all files under the terms of the New BSD Licence, or the GNU Public Licence (GPL) version 2 or 3, or the MIT Licence.

Tests
=====

[](#tests)

Tests are written for [Nette Tester](https://tester.nette.org), the Composer is required to run them:

```
# Download the Tester
composer update

# Run the tests
vendor/bin/tester tests
```

---

[![Build Status](https://camo.githubusercontent.com/5b87bc37536667793fd3f517726cb6585d358f6c49563a3977b889134055326e/68747470733a2f2f7472617669732d63692e6f72672f6d696c6f2f786d6c2d7270632e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/milo/xml-rpc)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 88.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~378 days

Total

5

Last Release

2258d ago

Major Versions

v1.0.0 → v2.0.02016-03-03

v2.2.0 → v3.0.02020-04-03

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.0

v2.0.0PHP &gt;=5.4.0

v3.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/a4c732343c0eba814891adfe91dea1754265ea7a5cbed1232d872cac406ff21e?d=identicon)[milonemilo](/maintainers/milonemilo)

---

Top Contributors

[![milo](https://avatars.githubusercontent.com/u/439140?v=4)](https://github.com/milo "milo (30 commits)")[![spagr](https://avatars.githubusercontent.com/u/6697111?v=4)](https://github.com/spagr "spagr (2 commits)")[![chapcz](https://avatars.githubusercontent.com/u/3541306?v=4)](https://github.com/chapcz "chapcz (1 commits)")[![trejjam](https://avatars.githubusercontent.com/u/3594540?v=4)](https://github.com/trejjam "trejjam (1 commits)")

### Embed Badge

![Health badge](/badges/milo-xml-rpc/health.svg)

```
[![Health](https://phpackages.com/badges/milo-xml-rpc/health.svg)](https://phpackages.com/packages/milo-xml-rpc)
```

###  Alternatives

[facebook/php-business-sdk

PHP SDK for Facebook Business

90923.5M35](/packages/facebook-php-business-sdk)[exsyst/swagger

A php library to manipulate Swagger specifications

35916.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
