Download the PHP package samuelterra22/laravel-report-generator without Composer

On this page you can find all versions of the php package samuelterra22/laravel-report-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-report-generator

Laravel Report Generator

Generate PDF, Excel & CSV reports from Eloquent queries with a fluent API.
Zero boilerplate. Full control. Works with Laravel 10, 11 & 12.

Latest Version on Packagist Tests Code Style Total Downloads PHP Version


Laravel Report Generator is a package that lets you build PDF, Excel (XLSX), and CSV reports directly from Eloquent queries or query builders using a clean, chainable API. Define columns, format values, group rows, add totals, customize styling -- all without writing HTML tables or spreadsheet logic by hand.

Key features:


Table of Contents


Requirements

PHP Laravel
8.2+ 10.x
8.2+ 11.x
8.2+ 12.x

Installation

Install the package via Composer:

The service provider and facades are auto-discovered -- no manual registration needed.

PDF engine (pick one)

To generate PDF reports, install one of the supported PDF engines:

If both are installed, Snappy is used by default with an automatic fallback to DomPDF.

CSV support (optional)

Quick Start

This generates a paginated PDF report with rows grouped by city, formatted currency values, and automatic totals per group.


Output Examples

Report with Grand Total

A report using showTotal() to display an automatic sum at the bottom:

Report with Group By

A report using groupBy() combined with showTotal() -- rows are grouped by date, with subtotals after each group and a final grand total:


Usage

PDF Reports

Output methods for PDF:

Method Description
make() Returns the PDF object (for further manipulation)
stream() Displays the PDF inline in the browser
download($filename) Forces a file download (.pdf extension added automatically)

Excel Reports

Simple version (direct sheet manipulation, better for large datasets):

Output methods for Excel:

Method Description
make() Returns the Excel object for further manipulation
download($filename) Exports and downloads the XLSX file
simpleDownload($filename) Forces simple mode and downloads

CSV Reports

Requires league/csv. The .csv extension is added automatically.

Output methods for CSV:

Method Description
download($filename) Outputs the CSV file for download

API Reference

Initializing a Report

Parameter Type Description
$title string Report title displayed in the header
$meta array Key-value pairs shown below the title (e.g., date range, filters)
$query Builder\|EloquentBuilder The query to iterate over
$columns array Column mapping: ['Display Name' => 'db_column']

Column mapping supports two formats:

Column Formatting

editColumn(string $columnName, array $options)

Customize how a column is displayed:

Option Type Description
class string CSS class applied to the column cells (left, right, bold)
displayAs Closure\|string Callback receiving the full row, or a static string value

editColumns(array $columnNames, array $options)

Apply the same formatting to multiple columns at once:

Built-in Column Formatters

Use formatColumn() for common formatting without writing closures. If a column has both editColumn with displayAs and formatColumn, the displayAs callback takes priority.

formatColumn(string $columnName, string $type, array $options = [])

formatColumns(array $columnNames, string $type, array $options = [])

Apply the same formatter to multiple columns:

Available format types:

Type Options Default output
currency prefix ($), decimals (2), decimal_separator (.), thousands_separator (,) $ 1,234.56
number decimals (0), decimal_separator (.), thousands_separator (,) 1,235
date format (Y-m-d) 2025-01-15
datetime format (Y-m-d H:i:s) 2025-01-15 14:30:00
percentage decimals (1), suffix (%) 75.0%
boolean true (Yes), false (No) Yes / No

Grouping & Totals

groupBy(string|array $column)

Group rows by one or more columns. When the group value changes, a subtotal row is inserted:

showTotal(array $columns)

Display totals for numeric columns. Each entry maps a column name to a display type:

Type Output format
'point' 1,234.56 (number only)
Any string PREFIX 1,234.56 (uppercased prefix + number)

Advanced aggregation types -- beyond sum, you can use:

Aggregation Description
sum Sum of all values (default for unknown types)
avg Arithmetic mean
min Minimum value
max Maximum value
count Number of rows
point Same as sum, but displayed without a label prefix

Conditional Formatting

Apply CSS styles to cells based on their values. In PDF/Excel reports the styles are applied as inline CSS. CSV reports ignore formatting gracefully.

conditionalFormat(string $columnName, callable $condition, array $styles)

The condition callback receives ($cellValue, $rowObject), so you can also style based on other columns:

Report Events / Hooks

Register callbacks that fire at specific points in the report lifecycle. Useful for logging, progress tracking, auditing, and post-processing.

Multiple callbacks can be registered for the same event -- they fire in registration order.

Custom Headers & Footers

Customize the header and footer content of PDF reports. Supports positional placement and placeholders.

setHeaderContent(string $content, string $position = 'center')

setFooterContent(string $content, string $position = 'center')

clearHeader() / clearFooter()

Remove all header or footer content:

Available placeholders:

Placeholder Description
{page} Current page number
{pages} Total page count
{date} Current date (Y-m-d)
{title} Report title

Defaults:

Multi-Format Export

Define a report once and export to multiple formats without duplicating configuration. Use ReportExporter to build the report, then call toPdf(), toExcel(), or toCsv().

ReportExporter supports all the same fluent methods as the individual report classes (editColumn, formatColumn, groupBy, showTotal, conditionalFormat, cacheFor, etc.).

Report Caching

Cache the rendered report output to avoid re-rendering on repeated requests. Cached HTML is stored via Laravel's cache system.

cacheFor(int $minutes)

Enable caching with a TTL in minutes:

cacheAs(string $key)

Set a custom cache key (otherwise an auto-generated key based on title, columns, meta, limit, and groupBy is used):

cacheUsing(string $store)

Use a specific cache store (e.g., redis, file, array):

noCache()

Explicitly disable caching (useful to override a previously set cacheFor):

On cache hit, the template rendering step is skipped entirely and the cached HTML is loaded directly into the PDF/CSV engine.

Layout & Styling

setPaper(string $size) (PDF only)

Set the paper size. Default: a4.

setOrientation(string $orientation) (PDF only)

Set page orientation. Default: portrait.

setCss(array $styles) (PDF & Excel)

Inject custom CSS rules into the report template:

showHeader(bool $value = true)

Show or hide the column header row. Default: true.

showMeta(bool $value = true)

Show or hide the meta information section. Default: true (except CSV, which defaults to false).

showNumColumn(bool $value = true)

Show or hide the auto-incrementing row number column (No). Default: true.

Performance

limit(int $n)

Limit the number of rows processed:

withoutManipulation()

Skip column editing logic entirely for faster generation. Uses a simpler template that renders raw column values:

simple() (Excel only)

Use direct sheet manipulation instead of Blade template rendering. Better for large datasets:


Configuration

Publish the config file:

This creates config/report-generator.php:

Customizing Templates

Publish the Blade templates to customize the report layout:

This publishes four templates to resources/views/vendor/laravel-report-generator/:

Template Used by
general-pdf-template.blade.php PDF reports with column manipulation
general-excel-template.blade.php Excel reports with column manipulation
without-manipulation-pdf-template.blade.php PDF reports using withoutManipulation()
without-manipulation-excel-template.blade.php Excel reports using withoutManipulation()

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-report-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^10.0||^11.0||^12.0
maatwebsite/excel Version ^3.1
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package samuelterra22/laravel-report-generator contains the following files

Loading the files please wait ...