A client that abstracts out the XML RPC calls for eXist-db for Laravel 5
bcdh/laravel-exist-db-client is a Laravel package for a client that abstracts out the xml rpc calls for exist-db for laravel 5.
It currently has 4 GitHub stars and 23 downloads on Packagist (latest version v1.0.1).
Install it with composer require bcdh/laravel-exist-db-client.
Discover more Laravel packages by bcdh
or browse all Laravel packages to compare alternatives.
Last updated
A Laravel 5 package that abstracts out the XML RPC calls for eXist-db. Based on php-eXist-db-Client.
sudo apt-get install php-pear
sudo pear channel-update pear.php.net
sudo apt-get install php5-xsl
####1. Add the service provider to your config/app.php:
BCDH\ExistDbClient\ExistDbServiceProvider::class
####2. Publish your configuration file:
php artisan vendor:publish
####3. Edit your connection credentials in config/exist-db.php
[
'protocol' => "http",
'user' => "admin",
'password' => "admin",
'host' => "localhost",
'port' => 8080,
'path' => "/exist/xmlrpc/",
]
use BCDH\ExistDbClient\ExistDbClient;
$connection = new ExistDbClient();
$stmt = $connection->prepareQuery('for $someNode in collection("/SomeCollection")/someNodeName[./somePredicateAttribute=$someValueToBeBound] return $someNode');
$stmt->setSimpleXMLReturnType();
$stmt->bindVariable('someValueToBeBound', '5');
$resultPool = $stmt->execute();
$result = $resultPool->getAllResults();
foreach($result as $xml) {
var_dump($xml->somePredicateAttribute);
}
Query::setStringReturnType() result is instance of DOMElement
Query::setSimpleXMLReturnType() result is instance of SimpleXMLElement
Query::setDomXMLReturnType() result is string
$document = $result->getDocument();
$title = $doc->getElementsByTagName('TITLE')->item(0)->nodeValue;
$document = $result->getDocument();
$title = $doc->TITLE;
$document = $result->getDocument();
$isFavorite = $doc->hasAttribute('favourite');
$document = $result->getDocument();
$attributes = $document->attributes();
$isFavorite = isset($attributes['favourite']);
$resultPool = $stmt->execute();
$results = $resultPool->getAllResults();
$res = $results[0];
$html = $res->transform(__DIR__.'/xml/cd_catalog_simplified.xsl');
$resultPool = $stmt->execute();
$results = $resultPool->getAllResults();
$rootTagName = 'catalog';
$html = $resultPool->transform($rootTagName, $results, __DIR__.'/xml/cd_catalog_simplified.xsl');