Download the PHP package rootwork/php-report-generator without Composer
On this page you can find all versions of the php package rootwork/php-report-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rootwork/php-report-generator
More information about rootwork/php-report-generator
Files in rootwork/php-report-generator
Package php-report-generator
Short Description A time-saving PHP reporting library.
License MIT
Homepage https://github.com/rootworkit/php-report-generator
Informations about the package php-report-generator
PHP Report Generator
A time-saving PHP reporting library.
NOTE: This package is currently alpha and unstable. As we use it and settle on a final set of features for first release, we'll look to make 1.0.0 our first stable tag.
Installation
Install composer in a common location or in your project:
Create the composer.json file as follows:
Run the composer installer:
Concepts
This library is designed to give developers a way to encapsulate reports with a single class.
Core Methods
Your report class should extend Rootwork\Report\ReportAbstract
and implement Rootwork\Report\ReportInterface
. This will give you two abstract public methods to implement in your class: define()
and run()
.
Definition, Columns and Variables
All reports have a Definition
object the defines the features of the report. You add Column
instances to define your columns and optional Variable
instances if you want to pass variable parameters to your report (for an SQL WHERE
clause for example).
Column($name, $display, $type, [$format = null, $total = false])
Variable($name, $display, $type, [$default = null, array $options = [], $format = null])
Data Sources
This library is currently data source agnostic. You are able to pass in and use any data source you like so long as you set an array of rows
at the end of your run()
method.
You may pass data sources and other dependencies to the constructor using the $options
array, and use them in the initialize()
method. The constructor will call initialize()
with the $options
array. Overriding __construct
is discouraged.
Usage
Example Report Class
Using Report Classes
You can serialize the report definition as JSON. This is useful if you want to auto generate forms for running reports.
Result:
The run()
method will return report rows but a more useful output is to encode the report as JSON.
Result: