README.md 1.11 KB
Newer Older
ZZZ[GONE] Lequeux Olivier's avatar
ZZZ[GONE] Lequeux Olivier committed
1 2 3 4 5 6 7
# Lavoisier Query 

A simple PHP static library to query a Lavoisier service and map the results to objects via hydrators.
Some basics hydrators are provided, but you will easily create your own.

## Requirements

Olivier Lequeux's avatar
Olivier Lequeux committed
8
* PHP 5.3
ZZZ[GONE] Lequeux Olivier's avatar
ZZZ[GONE] Lequeux Olivier committed
9 10
* enable cURL PHP extension

ZZZ[GONE] Lequeux Olivier's avatar
ZZZ[GONE] Lequeux Olivier committed
11 12 13 14

## Get Started

### Hydrate with SimpleXMLHydrator
ZZZ[GONE] Lequeux Olivier's avatar
ZZZ[GONE] Lequeux Olivier committed
15 16
```
$lquery = new \Lavoisier\Query('localhost','example');
ZZZ[GONE] Lequeux Olivier's avatar
ZZZ[GONE] Lequeux Olivier committed
17 18 19 20
$lquery->setPath("/data/products[@month='January']");
$lquery->setHydrator(new \Lavoisier\Hydrators\SimpleXMLHydrator());
$result = $lquery->execute();

ZZZ[GONE] Lequeux Olivier's avatar
ZZZ[GONE] Lequeux Olivier committed
21
// var_dump(results);
ZZZ[GONE] Lequeux Olivier's avatar
ZZZ[GONE] Lequeux Olivier committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
object(SimpleXMLElement)#2 (1) {
  ["products"]=>
  object(SimpleXMLElement)#4 (4) {
    ["@attributes"]=>
    array(1) {
      ["month"]=>
      string(7) "January"
    }
    ["A"]=>
    string(4) "8343"
    ["B"]=>
    string(4) "2446"
    ["average"]=>
    string(6) "5394.5"
  }
ZZZ[GONE] Lequeux Olivier's avatar
ascode3  
ZZZ[GONE] Lequeux Olivier committed
37 38
}
```
Olivier Lequeux's avatar
Olivier Lequeux committed
39 40 41 42 43

### EntriesHydrator
EntriesHydrator is an XML Hydrator which allows you to map any XML files which is matching to [ex_entries xsd schema](https://gitlab.in2p3.fr/opsportal/lavoisierquery/raw/master/ex_entries.xsd).
You can customize default binding by setting default|root|key binding to your own class.