2017 © Pedro Peláez
 

library laravel-exist-db-client

A client that abstracts out the XML RPC calls for eXist-db for Laravel 5

image

bcdh/laravel-exist-db-client

A client that abstracts out the XML RPC calls for eXist-db for Laravel 5

  • Tuesday, November 29, 2016
  • by ttasovac
  • Repository
  • 3 Watchers
  • 3 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

eXist-db Client for Laravel 5

A Laravel 5 package that abstracts out the XML RPC calls for eXist-db. Based on php-eXist-db-Client., (*1)

Requirements:

  • Laravel 5
  • PHP 5.5 or PHP 7
  • PEAR 1.10
sudo apt-get install php-pear
sudo pear channel-update pear.php.net
  • PHP XSLT extension
sudo apt-get install php5-xsl

Installing

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/",
]

Usage

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);
}

Return types

  • Query::setStringReturnType() result is instance of DOMElement, (*2)

  • Query::setSimpleXMLReturnType() result is instance of SimpleXMLElement, (*3)

  • Query::setDomXMLReturnType() result is string, (*4)

Get result field

  • DomXmlResult
$document = $result->getDocument();
$title = $doc->getElementsByTagName('TITLE')->item(0)->nodeValue;
  • SimpleXML
$document = $result->getDocument();
$title = $doc->TITLE;

Get result attribute

  • DomXmlResult
$document = $result->getDocument();
$isFavorite = $doc->hasAttribute('favourite');
  • SimpleXML
$document = $result->getDocument();
$attributes = $document->attributes();
$isFavorite = isset($attributes['favourite']);

XLS transformations

  • Single result (DomXmlResult|SimpleXmlResult)
$resultPool = $stmt->execute();
$results = $resultPool->getAllResults();
$res = $results[0];

$html = $res->transform(__DIR__.'/xml/cd_catalog_simplified.xsl');
  • ResultSet
$resultPool = $stmt->execute();
$results = $resultPool->getAllResults();
$rootTagName = 'catalog';

$html = $resultPool->transform($rootTagName, $results, __DIR__.'/xml/cd_catalog_simplified.xsl');

The Versions

29/11 2016

dev-dev

dev-dev https://github.com/bcdh/laravel-exist-db-client

A client that abstracts out the XML RPC calls for eXist-db for Laravel 5

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

laravel php exist-db

11/05 2016

v1.0.1

1.0.1.0 https://github.com/bcdh/laravel-exist-db-client

A client that abstracts out the XML RPC calls for eXist-db for Laravel 5

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

laravel php exist-db

02/05 2016

dev-master

9999999-dev https://github.com/bcdh/laravel-exist-db-client

A client that abstracts out the XML RPC calls for eXist-db for Laravel 5

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

laravel php exist-db