pwsdotru/unoserver-client
最新稳定版本:1.0.0
Composer 安装命令:
composer require pwsdotru/unoserver-client
包简介
PHP client for Unoserver
README 文档
README
PHP Client connect to remote UnoServer via XMLRPC.
Unoserver
Unoserver using LibreOffice as a server for converting documents.
Docker for usage Unoserver
Run for tests
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
Unoserve listen on localhost (127.0.0.1) and port 2003
For check that server start run script check-xmlrpc.php. It should output informatino about Unosrver and LibreOffice.
php -f check-xmlrpc.php
PHP
For 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-xmlrpc
php 8.3
dnf install php83-php-pecl-xmlrpc
Install
composer require pwsdotru/unoserver-client
Usage
Ping (info)
$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
$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
$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); }
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2026-04-26