PHPackages                             rootwork/php-report-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. rootwork/php-report-generator

ActiveLibrary

rootwork/php-report-generator
=============================

A time-saving PHP reporting library.

1.0.0(5y ago)41.0k2MITPHPPHP &gt;=5.4CI failing

Since Oct 6Pushed 5y ago3 watchersCompare

[ Source](https://github.com/rootworkit/php-report-generator)[ Packagist](https://packagist.org/packages/rootwork/php-report-generator)[ Docs](https://github.com/rootworkit/php-report-generator)[ RSS](/packages/rootwork-php-report-generator/feed)WikiDiscussions 1.x Synced 2mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

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
------------

[](#installation)

Install composer in a common location or in your project:

```
curl -s http://getcomposer.org/installer | php
```

Create the composer.json file as follows:

```
{
    "require": {
        "rootwork/php-report-generator": "0.1.0"
    }
}
```

Run the composer installer:

```
php composer.phar install
```

Concepts
--------

[](#concepts)

This library is designed to give developers a way to encapsulate reports with a single class.

### Core Methods

[](#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

[](#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

[](#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
-----

[](#usage)

### Example Report Class

[](#example-report-class)

```
