This is a simple, demonstration, CLI for the PHPBench Tabular library.
Tabular is a library for generating tabular reports from XML files.
Check the examples in the examples
folder of this repository, usage as
follows:
$ php bin/tabular report examples/books/books.xml examples/books/report.json
The following is the Tabular definition for the report:
{
"classes": {
"euro": [
[ "printf", {"format": "<info>€</info>%2d"} ]
]
},
"rows": [
{
"group": "body",
"cells": [
{
"name": "Title",
"expr": "string(./title)"
},
{
"name": "Stock",
"expr": "string(./stock)"
},
{
"name": "Price",
"class": "euro",
"expr": "number(./price)"
},
{
"name": "Author",
"expr": "string(./author)"
},
{
"name": "Stock Value",
"class": "euro",
"expr": "number(./price) * number(./stock)"
}
],
"with_query": ".//book"
},
{
"cells": []
},
{
"group": "footer",
"cells": [
{
"name": "Stock",
"literal": "Sum >>"
},
{
"name": "{{ cell.item }}",
"class": "euro",
"expr": "sum(//group[@name='body']//cell[@name='{{ cell.item }}'])",
"pass": 2,
"with_items": [ "Price", "Stock Value" ]
}
]
}
]
}