PHPackages                             gyselroth/document-engine-client - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. gyselroth/document-engine-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

gyselroth/document-engine-client
================================

PHP client for the document engine web service

0.1.0(7y ago)02.4kproprietaryPHPPHP &gt;=7.1.0

Since May 31Pushed 7y ago1 watchersCompare

[ Source](https://github.com/gyselroth/doc-engine-client)[ Packagist](https://packagist.org/packages/gyselroth/document-engine-client)[ Docs](http://www.gyselroth.com)[ RSS](/packages/gyselroth-document-engine-client/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

gyselroth Document Engine Client
================================

[](#gyselroth-document-engine-client)

Client library for the gyselroth Document Engine webservice

Minimum Requirements
--------------------

[](#minimum-requirements)

- PHP7.1 with extensions: json
- Build-tools: git, composer

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

[](#installation)

- Install via composer

```
composer require gyselroth/document-engine-client:dev-trunk
```

Usage
-----

[](#usage)

- Creating a minimal client

```
$client = new Gyselroth\DocumentEngine\Client([
    'baseUrl' => 'https://docengine.example.com'
]);
```

- Creating a client using HTTP basic authentication

```
$client = new Gyselroth\DocumentEngine\Client([
    'baseUrl' => 'https://docengine.example.com',
    'authenticationType' => 'basic',
    'username'    => 'foo',
    'password'    => 'bar'
]);
```

- Creating a client using Bearer authentication (e.g. oauth2, openid connect etc.)

```
$client = new Gyselroth\DocumentEngine\Client([
    'baseUrl' => 'https://docengine.example.com',
    'authenticationType' => 'bearer',
    'token'    => 'aBCdeFGHIJKlmnOpq1RsTu',
    'password'    => 'bar'
]);
```

- The Document Engine Client lets you use own http client implementations. Any chosen implementation must implements the GuzzleHttp\\ClientInterface interface.

```
$client = new Gyselroth\DocumentEngine\Client([
    'baseUrl' => 'https://docengine.example.com'
], new MyHttpClient());
```

### Validate template

[](#validate-template)

```
$template = new \SplFileObject('template.docx');
$validity = $client->validateTemplate($template);
```

### Get merge-fields from template

[](#get-merge-fields-from-template)

```
$template = new \SplFileObject('template.docx');
$mergefields = $client->getMergefields($template);
```

### Generate DOCX or PDF from template with given merge-data in a synchronous manner

[](#generate-docx-or-pdf-from-template-with-given-merge-data-in-a-synchronous-manner)

```
$template = new \SplFileObject('template.docx');
$mergeData = [
        'field1' => 'value1',
        'field2' => 'value2',
];
$docxStream = $client->generateDocx($template, $mergeData);
$pdfStream = $client->generatePdf($template, $mergeData);
```

*Note: The document generation methods return instances of `Psr\Http\Message\StreamInterface`. To read the stream into a file one can use a snippet like:*

```
fwrite(fopen('result.pdf', 'w+'), $pdfStream->read($pdfStream->getSize()));
```

### Generate Docx or PDF from template with given merge-data in an asynchronous manner

[](#generate-docx-or-pdf-from-template-with-given-merge-data-in-an-asynchronous-manner)

```
$template = new \SplFileObject('template.docx');
$mergeData = [
        'field1' => 'value1',
        'field2' => 'value2',
];
$jobId = $client->generateDocxAsync($template, $mergeData);
$jobId = $client->generatePdfAsync($template, $mergeData);
```

#### Check current status of a job

[](#check-current-status-of-a-job)

*Note: Gyselroth\\DocumentEngine\\Client::getJobStatus will - in every case, except for the annotated exceptions - return a string which equals to a constant from Gyselroth\\DocumentEngine\\JobStatus*

```
$jobStatus = $client->getJobStatus($jobId);
```

#### Get an asynchronously generated document

[](#get-an-asynchronously-generated-document)

```
$documentStream = $client->getDocument($jobId);
```

Exceptions
----------

[](#exceptions)

All public methods of the client can throw one of the following exceptions:

- `Gyselroth\DocumentEngine\Client\Auth\AuthException`
    - failed authorization (HTTP 401 Unauthorized), e.g. missing authentication
- `Gyselroth\DocumentEngine\Client\ClientException`
    - client side error (HTTP 4xx, but not HTTP 401 Unauthorized), e.g. HTTP 400 Bad Request
- `Gyselroth\DocumentEngine\Client\ServerException`
    - server side error (HTTP 5xx), e.g. HTTP 500 Internal Server Error
- `Gyselroth\DocumentEngine\Client\ConnectionException`
    - Networking error, e.g. server not reachable

Development Notes
-----------------

[](#development-notes)

### Installation after checkout

[](#installation-after-checkout)

```
composer update
```

Running Tests
-------------

[](#running-tests)

- Unit tests

```
composer unittest
```

- System tests

```
export DOCENG_CLIENT_TEST_BASEURL=http://example.com
export DOCENG_CLIENT_TEST_AUTH_TYPE=basic
export DOCENG_CLIENT_TEST_BASIC_USER=test
export DOCENG_CLIENT_TEST_BASIC_PASSWORD=secret
composer systemtest
```

- All tests

```
export DOCENG_CLIENT_TEST_BASEURL=http://example.com
export DOCENG_CLIENT_TEST_AUTH_TYPE=basic
export DOCENG_CLIENT_TEST_BASIC_USER=test
export DOCENG_CLIENT_TEST_BASIC_PASSWORD=secret
composer test
```

History
-------

[](#history)

See `CHANGELOG.md`

Author and License
------------------

[](#author-and-license)

Copyright 2017-2018 gyselroth™ ()

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

[http://www.apache.org/licenses/LICENSE-2.0":http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0%22:http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

### Used Open Source Software

[](#used-open-source-software)

Open source packages used by the gyselroth Document Engine Client are copyright of their vendors, see related licenses within the vendor packages.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2906d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48ce42c031ac21568fab6a2297d4687f393d93564415567abb5295706e9222df?d=identicon)[kstenschke](/maintainers/kstenschke)

---

Top Contributors

[![kstenschke](https://avatars.githubusercontent.com/u/1838456?v=4)](https://github.com/kstenschke "kstenschke (10 commits)")

---

Tags

clientrestpsr7servicedocument

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gyselroth-document-engine-client/health.svg)

```
[![Health](https://phpackages.com/badges/gyselroth-document-engine-client/health.svg)](https://phpackages.com/packages/gyselroth-document-engine-client)
```

###  Alternatives

[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[cybercog/youtrack-rest-php

YouTrack REST API PHP Client.

37149.2k3](/packages/cybercog-youtrack-rest-php)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[huaweicloud/huaweicloud-sdk-php

Huawei Cloud SDK for PHP

1829.2k2](/packages/huaweicloud-huaweicloud-sdk-php)[amphp/http-client-guzzle-adapter

Guzzle adapter for Amp's HTTP client.

1523.6k1](/packages/amphp-http-client-guzzle-adapter)[pdffiller/pdffiller-php-api-client

PHP client for pdffiller.com REST API

14140.2k](/packages/pdffiller-pdffiller-php-api-client)

PHPackages © 2026

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