PHPackages                             klongchu/bud-docuware - 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. klongchu/bud-docuware

ActiveLibrary[API Development](/categories/api)

klongchu/bud-docuware
=====================

DocuWare integration with Laravel

1.2.0(2mo ago)0631—0%MITPHPPHP ^8.2

Since Nov 10Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/klongchu/bud-docuware)[ Packagist](https://packagist.org/packages/klongchu/bud-docuware)[ Docs](https://github.com/klongchu/bud-docuware)[ RSS](/packages/klongchu-bud-docuware/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (30)Versions (6)Used By (0)

[![](https://camo.githubusercontent.com/0c12b34c54c4bcfa04c8e92c0bcf19600772fdfac7a79b38d7b341700eb9936b/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230446f6375576172652e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6b6c6f6e676368752532466c61726176656c2d646f637577617265267061747465726e3d63697263756974426f617264267374796c653d7374796c655f31266465736372697074696f6e3d416e2b6f70696e696f6e617465642b7761792b746f2b696e746567726174652b446f6375576172652b776974682b4c61726176656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313735707826696d616765733d646f63756d656e742d7265706f7274)](https://camo.githubusercontent.com/0c12b34c54c4bcfa04c8e92c0bcf19600772fdfac7a79b38d7b341700eb9936b/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230446f6375576172652e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6b6c6f6e676368752532466c61726176656c2d646f637577617265267061747465726e3d63697263756974426f617264267374796c653d7374796c655f31266465736372697074696f6e3d416e2b6f70696e696f6e617465642b7761792b746f2b696e746567726174652b446f6375576172652b776974682b4c61726176656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313735707826696d616765733d646f63756d656e742d7265706f7274)

[![Latest Version on Packagist](https://camo.githubusercontent.com/337aa366bbcd4f03a18daacc1030a8b8bcf05c8f5dad66aa8211d53811e6094b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6c6f6e676368752f6c61726176656c2d646f6375776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/klongchu/laravel-docuware)[![GitHub-Tests](https://github.com/klongchu/laravel-docuware/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/klongchu/laravel-docuware/actions/workflows/run-tests.yml)[![GitHub Code Style](https://github.com/klongchu/laravel-docuware/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/klongchu/laravel-docuware/actions/workflows/fix-php-code-style-issues.yml)[![Total Downloads](https://camo.githubusercontent.com/4ed1ddc84fe7db6cdb176d78933e917d8d0201211e518d779dafb9f427ee0d4a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6c6f6e676368752f6c61726176656c2d646f6375776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/klongchu/laravel-docuware)

This package was developed to give you a quick start to communicate with the DocuWare REST API. It is used to query the most common endpoints.

⚠️ This package is not designed as a replacement of the official [DocuWare REST API](https://developer.docuware.com/rest/index.html). See the documentation if you need further functionality. ⚠️

💡 What is DocuWare?
-------------------

[](#-what-is-docuware)

DocuWare provides cloud document management and workflow automation software that enables you to digitize, secure and work with business documents, then optimize the processes that power the core of your business.

🛠 Requirements
--------------

[](#-requirements)

### &gt; = v3.0

[](#--v30)

- PHP: `^8.2``
- Laravel: `^10.*`
- DocuWare Cloud Access

### &gt; = v2.0

[](#--v20)

- PHP: `^8.1` |`^8.2`
- Laravel: `^9.*` | `^10.*`
- DocuWare Cloud Access
-

### &gt; = v1.2

[](#--v12)

- PHP: `^8.1`
- Laravel: `^9.*`
- DocuWare Cloud Access

### &lt; v1.2

[](#-v12)

- PHP: `^8.0`
- Laravel: `^8.*`
- DocuWare Cloud Access

⚙️ Installation
---------------

[](#️-installation)

You can install the package via composer:

```
composer require klongchu/bud-docuware
```

Add the following environment variables to your `.env` file: The "DOCUWARE\_COOKIES" variable is optional and only used if you want to set the request cookie manually.

```
DOCUWARE_URL=https://domain.docuware.cloud
DOCUWARE_USERNAME=user@domain.test
DOCUWARE_PASSWORD=password
DOCUWARE_PASSPHRASE="passphrase"
DOCUWARE_COOKIES="cookie"
```

With the passphrase we are able to encrypt the URLs.

⚠️ You need to escape backslashes in your passphrase with another backslash:

```
# ❌ Passphrase contains a backslash and is not escaped:
DOCUWARE_PASSPHRASE="a#bcd>2~C1'abc\#"

# ✅ We need to escape the backslash with another backslash:
DOCUWARE_PASSPHRASE="a#bcd>2~C1'abc\\#"
```

🏗 Usage
-------

[](#-usage)

```
use Klongchu\DocuWare\Connectors\DocuWareStaticConnector;

// Will use user credentials defined in config to authenticate and store cookie in cache
$connector = new DocuWareStaticConnector();

// OR

// Pass in a config manually
$config = Config::make([
    'url' => 'https://domain.docuware.cloud',
    'cookie' => 'cookie',
    'cache_driver' => 'file',
    'cache_lifetime_in_seconds' => 60,
    'request_timeout_in_seconds' => 15,
]);

$connector = new DocuWareDynamicConnector($config);

/**
 * Return an organization.
 */
$organization = $connector->send(new GetOrganizationRequest($id))->dto();

/**
 * Return all organizations.
 */
$organizations = $connector->send(new GetOrganizationsRequest())->dto();

/**
 * Return all file cabinets.
 */
$fileCabinets = $connector->send(new GetFileCabinetsRequest())->dto();

/**
 * Return all fields of a file cabinet.
 */
$fields = $connector->send(new GetFieldsRequest($fileCabinetId))->dto();

/**
 * Return all dialogs of a file cabinet.
 */
$dialogs = $connector->send(new GetDialogsRequest($fileCabinetId))->dto();

/**
 * Return all used values for a specific field.
 */
$values = $connector->send(new GetSelectListRequest($fileCabinetId, $dialogId, $fieldName))->dto();

/**
 * Return a document.
 */
$document = $connector->send(new GetDocumentRequest($fileCabinetId, $documentId))->dto();

/**
 * Return all documents for a file cabinet.
 */
$documents = $connector->send(new GetDocumentRequest($fileCabinetId))->dto();

/**
 * Return image preview of a document.
 */
$content = $connector->send(new GetDocumentPreviewRequest($fileCabinetId, $documentId))->dto();

/**
 * Download single document.
 */
$content = $connector->send(new GetDocumentDownloadRequest($fileCabinetId, $documentId))->dto();

/**
 * Download multiple documents.
 *
 * Although there are no mentioned limits in the documentation,
 * it is not advisable to download more than 100 documents at once.
 *
 * Also note there is a default request timeout of 30 seconds.
 */
$content = $connector->send(new GetDocumentsDownloadRequest($fileCabinetId, $documentIds))->dto();

/**
 * Download a document thumbnail.
 */
$thumbnail = $connector->send(new GetDocumentDownloadThumbnailRequest($fileCabinetId, $documentId, $section))->dto();

/**
 * Update value of a indexed field.
 */
$value = $connector->send(new PutDocumentFieldsRequest($fileCabinetId, $documentId, [$fieldName => $newValue]))->dto()[$fieldName];

/**
 * Update multiple values of indexed fields.
 */
$values = $connector->send(new PutDocumentFieldsRequest($fileCabinetId, $documentId, [
    $fieldName => $newValue,
    $field2Name => $new2Value,
]))->dto();

/**
 * Upload new document.
 */
$document = $connector->send(new PostDocumentRequest($fileCabinetId, $fileContent, $fileName))->dto();

/**
 * Get total document count.
 */
$content = $connector->send(new GetDocumentCountRequest($fileCabinetId, $dialogId))->dto();

/**
 * Upload new document with index values.
 */
use Klongchu\DocuWare\DTO\DocumentIndex;

$indexes = collect([
    DocumentIndex::make('DOCUMENT_TEXT', 'Indexed Text'),
    DocumentIndex::make('DOCUMENT_NUMBER', 42),
]);

$document = $connector->send(new PostDocumentRequest(
    $fileCabinetId,
    $fileContent,
    $fileName,
    $indexes,
))->dto();

/**
 * Delete document.
 */
$connector->send(new DeleteDocumentRequest($fileCabinetId, $document->id))->dto();
```

🔍 Search usage
--------------

[](#-search-usage)

```
use Klongchu\DocuWare\Facades\DocuWare;
use Klongchu\DocuWare\Connectors\DocuWareStaticConnector;

$connector = new DocuWareStaticConnector();

/**
 * Most basic example to search for documents. You only need to provide a valid
 * file cabinet id.
 */
$fileCabinetId = '87356f8d-e50c-450b-909c-4eaccd318fbf';

$paginatorRequest = DocuWare::searchRequestBuilder()
    ->fileCabinet($fileCabinetId)
    ->get();

$paginator = $connector->send($paginatorRequest)->dto();

/**
 * Search in multiple file cabinets. Provide an array of file cabinet ids.
 */
$fileCabinetIds = [
    '0ee72de3-4258-4353-8020-6a3ff6dd650f',
    '3f9cb4ff-82f2-44dc-b439-dd648269064f',
];

$paginatorRequest = DocuWare::searchRequestBuilder()
    ->fileCabinets($fileCabinetIds)
    ->get();

$paginator = $connector->send($paginatorRequest)->dto();

/**
 * Find results on the next page.
 *
 * Default: 1
 */
$paginatorRequest = DocuWare::searchRequestBuilder()
    ->fileCabinet($id)
    ->page(2)
    ->get();

$paginator = $connector->send($paginatorRequest)->dto();

/**
 * Define the number of results which should be shown per page.
 *
 * Default: 50
 */
$paginatorRequest = DocuWare::searchRequestBuilder()
    ->fileCabinet($id)
    ->perPage(30)
    ->get();

$paginator = $connector->send($paginatorRequest)->dto();

/**
 * Use the full-text search. You have to activate full-text search in your file
 * cabinet before you can use this feature.
 */
$paginatorRequest = DocuWare::searchRequestBuilder()
    ->fileCabinet($id)
    ->fulltext('My secret document')
    ->get();

$paginator = $connector->send($paginatorRequest)->dto();

/**
 * Search documents which are created from the first of march.
 */
$paginatorRequest = DocuWare::searchRequestBuilder()
    ->fileCabinet($id)
    ->filterDate('DWSTOREDATETIME', '>=', Carbon::create(2021, 3, 1))
    ->get();

$paginator = $connector->send($paginatorRequest)->dto();

/**
 * Search documents which are created until the first of april.
 */
$paginatorRequest = DocuWare::searchRequestBuilder()
    ->fileCabinet($id)
    ->filterDate('DWSTOREDATETIME', '=', Carbon::create(2021, 3, 1))
    ->filterDate('DWSTOREDATETIME','
