Package Data | |
---|---|
Maintainer Username: | ttasovac |
Package Create Date: | 2016-05-09 |
Package Last Update: | 2016-11-08 |
Language: | PHP |
License: | GPL-2.0 |
Last Refreshed: | 2024-11-15 03:03:36 |
Package Statistics | |
---|---|
Total Downloads: | 340 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 4 |
Total Forks: | 2 |
Total Open Issues: | 1 |
A Laravel client for querying and transforming results from eXist-db via REST API.
sudo apt-get install php5-xsl
####1. Add the service provider to your config/app.php:
BCDH\ExistDbRestClient\ExistDbServiceProvider::class
####2. Publish your configuration file:
php artisan vendor:publish
####3. Edit your connection credentials in config/exist-db.php
[
'user' => 'admin',
'password' => 'admin',
'protocol' => 'http',
'host' => 'localhost',
'port' => 8080,
'path' => 'exist/rest',
/* alternatively, you can specify the URI as a whole in the form */
// 'uri'=>'http://localhost:8080/exist/rest/'
'xsl' => 'no',
'indent' => 'yes',
'howMany' => 10,
'start' => 1,
'wrap' => 'yes'
]
use BCDH\ExistDbRestClient\ExistDbRestClient;
$q = 'for $cd in /CD[./ARTIST=$artist] return $cd';
$connection = new ExistDbRestClient();
$query = $connection->prepareQuery();
$query->bindVariable('artist', 'Bonnie Tyler');
$query->setCollection("CDCatalog");
$query->setQuery($q);
$result = $query->get();
$document = $result->getDocument();
sabre/xml library is used for parsing xml result. You can pass an instance of \Sabre\Xml\Service with your own (de)serializers to Query request methods
array(
array(
'name' => '{}CD',
'value' => array(
0 => array(
'name' => '{}TITLE',
'value' => 'Empire Burlesque',
'attributes' => array(),
),
1 => array(
'name' => '{}ARTIST',
'value' => 'Bob Dylan',
'attributes' => array(),
),
2 => array(
'name' => '{}COUNTRY',
'value' => 'USA',
'attributes' => array(),
),
3 => array(
'name' => '{}COMPANY',
'value' => 'Columbia',
'attributes' => array(),
)
),
'attributes' => array (
'favourite' => '1',
),
),
);
$result = $query->get();
$document = $result->getDocument();
$singleCd = $document[0];
$html = $result->transform(__DIR__ . '/xml/cd_catalog_simplified.xsl', $singleCd);
$result = $query->get();
$document = $result->getDocument();
$rootTagName = '{}catalog';
$html = $result->transform(__DIR__ . '/xml/cd_catalog_simplified.xsl', $document, $rootTagName);