PHPackages                             bcdh/exist-db-rest-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. bcdh/exist-db-rest-client

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

bcdh/exist-db-rest-client
=========================

A Laravel client for querying and transforming results from eXist-db via the REST API

v1.2.0(2mo ago)3647↓46.7%2GPL-2.0-onlyPHPPHP ^8.0.2CI passing

Since May 10Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/BCDH/Laravel-eXist-db-REST-Client)[ Packagist](https://packagist.org/packages/bcdh/exist-db-rest-client)[ Docs](https://github.com/BCDH/Laravel-eXist-db-REST-Client)[ RSS](/packages/bcdh-exist-db-rest-client/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (12)Versions (8)Used By (0)

Laravel eXist-db REST Client
============================

[](#laravel-exist-db-rest-client)

A small Laravel-friendly client for querying eXist-db over its REST API, parsing XML responses, and applying XSLT transformations.

Version compatibility
---------------------

[](#version-compatibility)

- `1.1.x`: Laravel 8
- `1.2.x` (`v1.2.0`): Laravel 9
- `1.3.x`: planned for Laravel 10
- `2.x`: planned for Laravel 11+

The latest released bridge line is `1.2.x` for Laravel 9.

The default branch, `master`, is the development branch. Use a tagged release when installing the package in an application.

Requirements
------------

[](#requirements)

Current `master` branch requirements:

- PHP `^7.2|^8.0`
- Laravel / `illuminate/support` `^5.5|^6.0|^7.0|^8.0`
- PHP XSL extension for XSLT transformations
- An accessible eXist-db REST endpoint

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

[](#installation)

Install the version that matches your Laravel line:

```
composer require bcdh/exist-db-rest-client:^1.2   # Laravel 9
```

For Laravel 8, use:

```
composer require bcdh/exist-db-rest-client:^1.1
```

Laravel package discovery will register the service provider automatically.

If you are integrating the package into an older Laravel application without package discovery, register the provider manually in `config/app.php`:

```
BCDH\ExistDbRestClient\ExistDbServiceProvider::class,
```

Publish the package configuration:

```
php artisan vendor:publish --provider="BCDH\ExistDbRestClient\ExistDbServiceProvider"
```

Then adjust `config/exist-db.php`:

```
return [
    'user' => 'admin',
    'password' => 'admin',

    'protocol' => 'http',
    'host' => 'localhost',
    'port' => 8080,
    'path' => 'exist/rest',

    // Alternatively, provide the full base URI.
    // 'uri' => 'http://localhost:8080/exist/rest/',

    'xsl' => 'no',
    'indent' => 'yes',
    'howMany' => 10,
    'start' => 1,
    'wrap' => 'yes',
];
```

Basic usage
-----------

[](#basic-usage)

```
use BCDH\ExistDbRestClient\ExistDbRestClient;

$xquery = 'for $cd in /CD[./ARTIST = $artist] return $cd';

$client = new ExistDbRestClient();
$query = $client->prepareQuery();

$query->setCollection('CDCatalog');
$query->setQuery($xquery);
$query->bindVariable('artist', 'Bonnie Tyler');

$result = $query->get();
$document = $result->getDocument();
```

`getDocument()` returns the parsed XML result. `getRawResult()` returns the raw XML string from eXist-db.

Using the client outside Laravel
--------------------------------

[](#using-the-client-outside-laravel)

You can also pass configuration directly:

```
use BCDH\ExistDbRestClient\ExistDbRestClient;

$client = new ExistDbRestClient([
    'uri' => 'http://localhost:8080/exist/rest/',
    'user' => 'admin',
    'password' => 'admin',
    'xsl' => 'no',
    'indent' => 'yes',
    'howMany' => 0,
    'start' => 1,
    'wrap' => 'yes',
]);
```

Query helpers
-------------

[](#query-helpers)

`Query` supports:

- `setQuery($xquery)` for inline XQuery
- `setStoredQuery($path)` for stored XQuery resources
- `setCollection($collection)`
- `setResource($resource)`
- `bindVariable($name, $value)` for XQuery variable substitution
- `bindParam($name, $value)` for request parameters
- `setBody($body)` for request payloads
- `get()`, `post()`, `put()`, and `delete()`

Example with a stored query and request parameter:

```
$query = $client->prepareQuery();
$query->setStoredQuery('cd.xql');
$query->bindParam('price', 7.9);

$result = $query->get();
```

Example uploading XML into a collection:

```
$query = $client->prepareQuery();
$query->setCollection('CDCatalog');
$query->setResource('new-record.xml');
$query->setBody($xml);

$query->put();
```

Result parsing
--------------

[](#result-parsing)

Results are parsed with [`sabre/xml`](http://sabre.io/xml/reading/). You can pass your own `Sabre\Xml\Service` instance to any request method:

```
use Sabre\Xml\Service;

$service = new Service();

$result = $query->get($service);
$document = $result->getDocument();
```

Typical parsed output looks like this:

```
[
    [
        'name' => '{}CD',
        'value' => [
            [
                'name' => '{}TITLE',
                'value' => 'Empire Burlesque',
                'attributes' => [],
            ],
            [
                'name' => '{}ARTIST',
                'value' => 'Bob Dylan',
                'attributes' => [],
            ],
        ],
        'attributes' => [
            'favourite' => '1',
        ],
    ],
]
```

XSLT transformations
--------------------

[](#xslt-transformations)

`XMLResult::transform()` applies an XSL stylesheet to either the full document or a selected fragment.

Transform a single result node:

```
$result = $query->get();
$document = $result->getDocument();
$singleCd = $document[0];

$html = $result->transform(__DIR__ . '/xml/cd_catalog_simplified.xsl', $singleCd);
```

Transform a collection of nodes with a custom root tag:

```
$result = $query->get();
$document = $result->getDocument();

$html = $result->transform(
    __DIR__ . '/xml/cd_catalog_simplified.xsl',
    $document,
    '{}catalog'
);
```

Running tests
-------------

[](#running-tests)

The test suite expects a local eXist-db instance at `http://localhost:8080/exist/rest/` with the default `admin/admin` credentials.

Run:

```
composer test
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance87

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

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

Every ~605 days

Recently: every ~907 days

Total

7

Last Release

65d ago

PHP version history (3 changes)v1.0.0PHP ~5.5|~7.0

v1.1.0PHP ^7.2|^8.0

1.x-devPHP ^8.0.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5304839?v=4)[Toma Tasovac](/maintainers/ttasovac)[@ttasovac](https://github.com/ttasovac)

---

Top Contributors

[![ttasovac](https://avatars.githubusercontent.com/u/5304839?v=4)](https://github.com/ttasovac "ttasovac (16 commits)")[![zilbertrubb](https://avatars.githubusercontent.com/u/15800940?v=4)](https://github.com/zilbertrubb "zilbertrubb (14 commits)")

---

Tags

phplaravelrestxslteXist-dbxquery

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/bcdh-exist-db-rest-client/health.svg)

```
[![Health](https://phpackages.com/badges/bcdh-exist-db-rest-client/health.svg)](https://phpackages.com/packages/bcdh-exist-db-rest-client)
```

###  Alternatives

[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[dreamfactory/df-core

DreamFactory(tm) Core Components

1652.0k38](/packages/dreamfactory-df-core)

PHPackages © 2026

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