PHPackages                             md0/regenerator - 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. [Framework](/categories/framework)
4. /
5. md0/regenerator

ActiveLibrary[Framework](/categories/framework)

md0/regenerator
===============

Laravel ReGenerator

343[1 issues](https://github.com/md0-code/regenerator/issues)PHP

Since Oct 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/md0-code/regenerator)[ Packagist](https://packagist.org/packages/md0/regenerator)[ RSS](/packages/md0-regenerator/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

ReGenerator for Laravel
=======================

[](#regenerator-for-laravel)

**A quick report generator for Laravel based on SQL queries.**

This is a tool intended for site/app admins that need to quickly create decent looking reports for display or export using only SQL select statements and a few parameters. Uses Bootstrap 3/4 classes for formatting, but can also output to an array if you need to customize the final look.

This package does not include a GUI for managing the reports. Please check out [ReGenerator for Backpack](https://github.com/md0-code/backpack-regenerator) if you need to edit reports from the admin interface.

Should work on any version of Laravel above 5.6, but was only tested on v8.

- [ReGenerator for Laravel](#regenerator-for-laravel)
    - [Installation](#installation)
        - [Optional](#optional)
    - [Usage](#usage)
    - [Getting started](#getting-started)
    - [Reference](#reference)
        - [Properties](#properties)
    - [Overwriting](#overwriting)
        - [Changinng the default parameters](#changinng-the-default-parameters)
        - [Customizing the PDF layout](#customizing-the-pdf-layout)
        - [Customizing the chart options](#customizing-the-chart-options)
    - [Errors &amp; Suggestions](#errors--suggestions)
    - [License](#license)
    - [Acknowledgements](#acknowledgements)

Installation
------------

[](#installation)

Require the package via Composer:

```
composer require md0/reportgenerator
```

Run the database migrations:

```
php artisan migrate
```

### Optional

[](#optional)

Publish the assets (only needed for charts):

```
php artisan vendor:publish --provider="MD0\ReGenerator\ReGeneratorServiceProvider" --tag="assets"
```

Publish the configuration file (to modify the default settings for new reports):

```
php artisan vendor:publish --provider="MD0\ReGenerator\ReGeneratorServiceProvider" --tag="config"
```

Publish the views (to modify the chart options and/or PDF headers):

```
php artisan vendor:publish --provider="MD0\ReGenerator\ReGeneratorServiceProvider" --tag="views"
```

Publish the language files. There are only three translatable strings (for the aggregate functions) so you can either edit them inside *resources/lang/vendor/regenerator* folder or just add them to your main translation file.

```
provider="MD0\ReGenerator\ReGeneratorServiceProvider" --tag="lang"
```

Usage
-----

[](#usage)

To use ReGenerator you can either:

1. use the class dinamically

```
use MD0\ReGenerator\Report;
class MyClass {
function report() {
	$report = new Report;
	$myReport = $report->setReport('my_report')->getHtml();
	}
}
```

2. use the **Report** facade

```
use MD0\ReGenerator\Facades\Report;
class MyClass {
	function report() {
		Report::setReport('my_report')->getHtml();
	}
}
```

Getting started
---------------

[](#getting-started)

To get started, all you need is access to the table/tables from which you need to extract the raports and your actual select statement:

```
Report::set('query', 'select name, email from users')->getHtml();
```

This will generate an ad-hoc (on the fly) report. To create a permanent report using a default set of options use the **create** method:

```
Report::create('my_report', 'select name, email from users')->getHtml();
```

This will add a new report to the database and generate it in HTML form. You may then include it as a variable anywhere on your view.

To access a previously created report you need to use the **setReport** method and (optionally) **set** any custom preferences before generating it:

```
Report::setReport('my_report')
		->set('pdfPageSize', 'letter')
		->set('pdfPageOrientation', 'landscape')
		->getPdf();
```

To make any customization permanent use the **update** method:

```
Report::setReport('my_report')->update('PdfPageSize', 'letter');
```

Check the next section for a complete list of methods and properties that you can use with ReGenerator.

Reference
---------

[](#reference)

### Properties

[](#properties)

Each report can have one or more associated properties that can be set at runtime or commited to the database:

- **name** *\[mandatory for saving\]*: a uniqe name for the report. Only alphanumeric characters, dashes or underscores.
- **query** *\[mandatory\]*: SQL query used to generate the report. Use standard blade markup (*{{ }}*) to include parameters if neccessary.
- **database**: database name as defined in Laravel. Leave empty for default. Make sure to use the Laravel defined name and not the actual database name.
- **title**: A descriptive title for the report. Can also have substitutable content (parameters).
- **reportType**: the type of report to generate. Defaults to *vertical* (classic), use *horizontal* for pivoted reports (columns on rows), or *slices* for individual records.
- **tag**: tag for grouping reports into collections. Leave empty if not needed.
- **numericCols**: comma separated list of column numbers that contain numeric values.
- **thousandsSeparator**: character used as thousands separator. Defaults to *dot*.
- **decimalsSeparator**: character used as decimals separator. Defaults to *comma*.
- **countCols**: comma separated list of column numbers that will feature a count total.
- **sumCols**: comma separated list of column numbers that will feature a sum aggregate.
- **averageCols**: comma separated list of column numbers that will feature a average aggregate.
- **pdfPageSize**: as used by DomPdf, defaults to A4.
- **pdfPageOrientation**: pdf page orientation, portrait or landscape.
- **pdfFontSize**: pdf font size. In points, defaults to 10.
- **pdfTemplate**: custom view to be used for wrapping the PDF report. Leave empty to use the default.
- **csvQuotes**: type of quotes for enclosing CSV fields. Defaults to none.
- **csvDelimiter**: CSV field delimiter. Usually comma or semicolon, defaults to comma.
- **chartType**: the type of chart that will be generated. Choose between *lines*, *bars* and *pie*. Defaults to *lines*.
- **chartSeries**: comma separated list of columns that hold the chart series.
- **chartLabels**: column number that holds the chart labels.
- **chartColors**: comma separated list of hex color codes to be used in chart.
- **chartTemplate**: custom view to be used for the generated chart. Leave empty to use the default.
- **parameters**: strings to be substituted in SQL queries. In the example below the {{condition1}} and {{condition2}} strings will be replaced in the SQL query.

```
$validParameters = [
    'condition1' => 'where active=1',
    'condition2' => 'and verified=1',
];
```

### Methods

[](#methods)

```
setReport(string $name): object | bool
```

Sets the active report.

- **name** - the name of the report.

---

```
set(string $property, string $value): object
```

Sets a property for the current report. Can be used with stored reports (after **setReport()**) or chained with itself to generate ad-hoc reports.

- **property** - report property to match;
- **value** - value to assign to the property.

---

```
getValue(int $line, int $column): string | bool
```

Returns a specific value from a report, useful when you have fixed size (x/y) reports.

- **line** - the line in the report;
- **column** - the column in the report.

---

```
getArray(): string
```

Returns the current report as associative array. Must be called after **setReport()** or **set()**.

---

```
getHtml(): string
```

Returns the current report as HTML formatted using Bootstrap classes. Must be called after **setReport()** or **set()**.

---

```
getPdf(): string
```

Returns the current report as a PDF file within a variable. Must be called after **setReport()** or **set()**. To display or download the PDF file set the *Content-Type* and *Content-Disposition* header directives:

```
return response()->make($pdfReport, 200, [
	'Content-Type' => 'application/pdf',
	'Content-Disposition' => 'inline; filename="test.pdf"',
]);
```

---

```
getChart(): string
```

Returns the current report as canvas Chart, ready to be inserted into any view. Must be called after **setReport()** or **set()**.

---

```
getReports([string $property], [string $value]): array | bool
```

Returns an array containing all the reports matching a set criteria. If no property is provided the method returns a list of all available reports.

- **property** - property to match;
- **value** - specific value for the property to filter reports on.

---

```
create(string $name, string $query, [string $database], [array $parameters]): object | bool
```

Creates a new report entry in the database.

- **name** - a unique name for the report;
- **query** - the complete SQL query to be executed; if parameters are present the 4th argument must also be supplied;
- **database** - the Laravel name of an alternative database to run the query against;
- **parameters** - array containing a list of parameter names and values to substituted inside the SQL query prior to execution.

---

```
 update(string | array $data, [string $value]): object | bool
```

Updates a report. Must be called after the **setReport()** method.

- **data** - can be either a single property of the report or an array containing property - value pairs;
- **value** - the value associated with a single property. Not needed for bulk updates.

---

```
delete(): bool
```

Deletes a report. Must be called after the **setReport()** method.

Overwriting
-----------

[](#overwriting)

### Changinng the default parameters

[](#changinng-the-default-parameters)

To change the default parameters for new reports publish the config file as described above and adjust the **defaults** array to your liking.

### Customizing the PDF layout

[](#customizing-the-pdf-layout)

To overwrite the default PDF page layout (to add a logo, etc.), publish the views and edit *views/vendor/md0/regenerator/pdf/report.blade.php* to suit your needs. If you need multiple templates create your own views and point to them with the *pdfTemplate* property.

### Customizing the chart options

[](#customizing-the-chart-options)

Use if you need to tweak Chart.js's settings publish the views and edit *views/vendor/md0/regenerator/chart/report.blade.php*. If you need multiple templates create your own views and point to them with the *chartTemplate* property.

Errors &amp; Suggestions
------------------------

[](#errors--suggestions)

Please send your improvement suggestions or report bugs / errors in the `Issues` section.

License
-------

[](#license)

Distributed under the GPL-3.0 License. See `LICENSE` for more information.

Acknowledgements
----------------

[](#acknowledgements)

ReGenerator uses the following open source libraries to generate raports. Please consult their respective pages for more information on usage and available customizations:

- [Dompdf](https://github.com/dompdf/dompdf)
- [Chart.js](https://github.com/chartjs/Chart.js)

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4744646?v=4)[md0](/maintainers/md0)[@md0](https://github.com/md0)

---

Top Contributors

[![md0-code](https://avatars.githubusercontent.com/u/17587578?v=4)](https://github.com/md0-code "md0-code (10 commits)")

### Embed Badge

![Health badge](/badges/md0-regenerator/health.svg)

```
[![Health](https://phpackages.com/badges/md0-regenerator/health.svg)](https://phpackages.com/packages/md0-regenerator)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M829](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[pinguo/php-msf

Pinguo Micro Service Framework For PHP

1.7k4.2k](/packages/pinguo-php-msf)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
