This PHP 7 library is a (very) simple client for zrrrzzt/tfk-api-unoconv and in particular its Docker implementation. The library is fully PSR-7 compatible and uses Guzzle as its HTTP client.
<?php
use CodeInc\UnoconvClient\UnoconvClient;
$client = new UnoconvClient('http://localhost:3000');
// lists supported formats (calls /unoconv/formats)
$client->getFormats();
// list supported format for the graphics type (calls /unoconv/formats/graphics)
$client->getFormats('graphics');
// returns the API server's uptime (calls /healthz)
$client->getHealth();
// returns all versions of installed dependencies lookup (calls /unoconv/versions)
$client->getVersions();
// converts a document
$responseStream = $client->convert($sourceStream, 'pdf');
<?php
use CodeInc\UnoconvClient\UnoconvClient;
use GuzzleHttp\Psr7\LazyOpenStream;
$client = new UnoconvClient('http://localhost:3000');
$localFilePath = '/path/to/my/document.docx';
$localFileStream = new LazyOpenStream($localFilePath, 'r');
$responseStream = $client->convert($localFileStream, 'pdf');
header('Content-Type: application/pdf');
echo $responseStream;
<?php
use CodeInc\UnoconvClient\UnoconvClient;
use GuzzleHttp\Psr7\LazyOpenStream;
use function GuzzleHttp\Psr7\copy_to_stream;
$client = new UnoconvClient('http://localhost:3000');
$localFilePath = '/path/to/my/document.docx';
$localFileStream = new LazyOpenStream($localFilePath, 'r');
$responseStream = $client->convert($localFileStream, 'pdf');
$pdfFilePath = '/path/to/my/document.pdf';
$pdfFileStream = new LazyOpenStream($pdfFilePath, 'w');
copy_to_stream($responseStream, $pdfFileStream);
This library is available through Packagist and can be installed using Composer:
composer require codeinc/unoconv-webservice-client
The library is published under the MIT license (see LICENSE
file).