PHP Client for connect to remote UnoServer via XMLRPC.
Unoserver using LibreOffice as a server for converting documents.
Docker for usage Unoserver
Docker files for tests in folder ./tests/docker/
File ./docker-compose.yml for operations with Docker container
Build container (command in project root)
docker-compose build
Start container for tests (command in project root)
docker-compose up
Unoserver listen on localhost (127.0.0.1) and port 2003
For check that server runing use script check-xmlrpc.php. It should output informatino about Unoserver and LibreOffice.
php -f check-xmlrpc.phpFor correct work client need module xmlrpc
XML-RPC support in PHP is not enabled by default. You will need to use the --with-xmlrpc[=DIR] configuration option when compiling PHP to enable XML-RPC support.
Or install module
php 7.4
dnf install php74-php-xmlrpcphp 8.3
dnf install php83-php-pecl-xmlrpccomposer require pwsdotru/unoserver-client
$ping = new UnoserverClient\Ping($host, $port);
if ($ping->call()) {
$result = $ping->result();
echo("Ping result:\n");
print_r($result);
} else {
$errors = $ping->errors();
echo("Ping errors:\n");
print_r($errors);
}$convert = new UnoserverClient\Convert($host, $port);
$convert->setOutputFormat($format);
if (false === $convert->loadFile($filename)) {
printf("Error. Can't load file.\n%s\n", implode("\n", $convert->errors()));
exit(3);
}
if ($convert->call()) {
$resultfile = $filename . "." . $format;
if ($convert->saveFile($resultfile)) {
printf("Convert result: %s\n", $resultfile);
} else {
$errors = $convert->errors();
echo("Save result errors:\n");
print_r($errors);
}
} else {
$errors = $convert->errors();
echo("Convert errors:\n");
print_r($errors);
}$compare = new UnoserverClient\Compare($host, $port);
$compare->setOutputFormat($format);
if (false === $compare->loadOldFile($oldname)) {
printf("Error. Can't load old file: %s.\n%s\n", $oldname, implode("\n", $compare->errors()));
exit(3);
}
if (false === $compare->loadNewFile($newname)) {
printf("Error. Can't load new file %s.\n%s\n", $newname, implode("\n", $compare->errors()));
exit(3);
}
if ($compare->call()) {
$resultfile = "compareresult." . $format;
if ($compare->saveFile($resultfile)) {
printf("Compare result: %s\n", $resultfile);
} else {
$errors = $compare->errors();
echo("Save result errors:\n");
print_r($errors);
}
} else {
$errors = $compare->errors();
echo("Compare errors:\n");
print_r($errors);
}