PHPackages                             mokhosh/laravel-reporter - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. mokhosh/laravel-reporter

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

mokhosh/laravel-reporter
========================

Create PDF and Excel reports in Laravel and style them with Tailwind CSS.

v0.15.5(4y ago)890[1 issues](https://github.com/mokhosh/laravel-reporter/issues)MITPHPPHP ^8.0

Since Jan 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mokhosh/laravel-reporter)[ Packagist](https://packagist.org/packages/mokhosh/laravel-reporter)[ Docs](https://github.com/mokhosh/laravel-reporter)[ RSS](/packages/mokhosh-laravel-reporter/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (5)Versions (23)Used By (0)

Create PDF and Excel reports in Laravel and style them with Tailwind CSS
========================================================================

[](#create-pdf-and-excel-reports-in-laravel-and-style-them-with-tailwind-css)

[![Latest Version on Packagist](https://camo.githubusercontent.com/309918d4b5417da64de6ebc8b125610e88b7d53c652c4b9530ec165f03f9acfb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f6b686f73682f6c61726176656c2d7265706f727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mokhosh/laravel-reporter)[![Total Downloads](https://camo.githubusercontent.com/f8eebf411f52682125d376bff676d09d0ac392b836dff7165d6f7d6928f9d437/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f6b686f73682f6c61726176656c2d7265706f727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mokhosh/laravel-reporter)

This is basically going to be a wrapper for an Excel generator and a Pdf generator. For the time being these generators are Maatweb and Barry's snappy, that might change in the future.

There is already a package that does this, but I didn't like the API, the coding style and the overall design, with all due respect of course.

Requirements
------------

[](#requirements)

This package requires PHP 8.

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

[](#installation)

You can install the package via composer. Make sure to run the Artisan install command to install npm dependencies.

```
composer require mokhosh/laravel-reporter
php artisan reporter:install
```

You shouldn't need to do anything else on your client. But on some servers you might need more dependencies. For example on Ubuntu you can run `ldd chrome | grep not` and it will give you a list of dependencies that Headless Chrome needs to run but you don't have. Then you can install them by running `apt install`. Here's a guide to help you with that:

Usage
-----

[](#usage)

This is the simplest way to get a PDF. This will report all non-hidden columns:

```
use Mokhosh\Reporter\Reporter;

$users = User::query();

return Reporter::report($users)->pdf(); // view in browser, aka inline
```

If you prefer to download the PDF file instead of showing it in the browser you can do this:

```
return Reporter::report($users)->download()->pdf(); // download, aka attachment
```

You can download the Excel version of your report:

```
return Reporter::report($users)->excel();
```

### Styles and Transforms

[](#styles-and-transforms)

If you don't pass a filter, `Reporter` will use your database columns to create its table. But if you use a filter, you can use any `accessor` on your model, and you can filter out some columns like this

```
$filter = [
    'id',
    'name',
    'email',
    'created_at',
];
return Reporter::report($users, $filter)->pdf();
```

That will use a Title Case version of column names for your table headers. If you wish to use custom table headers you can do so like this:

```
$filter = [
    'id' => 'ID',
    'email' => '@',
    'created_at' => 'Joined',
];
```

You can also transform the data by passing a closure:

```
$filter = [
    'created_at' => fn($date) => $date->format('Y-m'),
];
```

You can add Tailwind CSS classes to your table cells if you want. Cool, right?

```
$filter = [
    'id' => [
        'class' => 'font-bold text-gray-600 bg-gray-50'
    ],
];
```

You can also mix and match in a million ways:

```
$filter = [
    'id' => 'ID',
    'name',
    'email' => [
        'transform' => fn($email) => strtoupper($email),
        'class' => 'text-green-700 bg-green-100',
    ],
    'created_at' => fn($date) => $date->format('Y-m'),
    'updated_at' => [
        'title' => 'Last Seen',
        'class' => 'text-red-400',
    ],
];
```

The whole `model` is also passed to the `transform` closure, so you can access other columns if needed:

```
$filter = [
    'amount' => fn($amount, $model) => $model->currency . $amount,
];
```

With this you can even create made-up columns that don't exist on your model and in your database:

```
$filter = [
    'madeup_name' => fn($_, $model) => $model->amount * $model->discount,
];
```

Note that because this column does not really exist as a database column or even an accessor on your model, the first argument will be `null`. That's why I've named it `$_`.

You can also change the Title of the generated pdf and add metadata

```
$title = 'Users Report';
$meta = [
    'Admin' => 'Mo Khosh',
];

return Reporter::report($query, $columns, $title, $meta, footer: true)->pdf();
```

You can decide to show generation date, total pages and page number in footer

```
return Reporter::report($query, $columns, footer: true)->pdf();
```

You can put your logo in the header

```
return Reporter::report($query, $columns, logo: 'https://address-to-logo.com')->pdf();
```

TODO
----

[](#todo)

- I'm thinking of adding header classes

```
$filter = [
    'id' => 'ID',
    'email' => [
        'class' => 'text-green-700 bg-green-100',
        'header-class' => 'text-green-100 bg-green-700',
    ],
];
```

I'm also thinking of conditional classes that are added to a cell when its content meets a condition passed through a closure that returns a boolean value.

```
$filter = [
    'created_at' => [
        'conditional-classes' => [
            [
                'class' => 'text-red-600',
                'condition' => fn($date) => $date->gt(now()->subWeek()),
            ],
            [
                'class' => 'text-green-600',
                'condition' => fn($date) => $date->lt(now()->subYear()),
            ],
        ],
    ],
];
```

- A good API for is passing default styles for the table header, and even/odd rows
- Add headers and footers with page number, date, etc.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Mo Khosh](https://github.com/mokhosh)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~17 days

Recently: every ~0 days

Total

22

Last Release

1601d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/939919859a4e4f8e56b5771bc355135f44d98d8a3926baa6ce4358d2dc090edf?d=identicon)[mokhosh](/maintainers/mokhosh)

---

Top Contributors

[![mokhosh](https://avatars.githubusercontent.com/u/6499685?v=4)](https://github.com/mokhosh "mokhosh (108 commits)")

---

Tags

laravelpdftailwindmokhoshlaravel-reporter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mokhosh-laravel-reporter/health.svg)

```
[![Health](https://phpackages.com/badges/mokhosh-laravel-reporter/health.svg)](https://phpackages.com/packages/mokhosh-laravel-reporter)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[elibyy/tcpdf-laravel

tcpdf support for Laravel 6, 7, 8, 9, 10, 11

3542.7M5](/packages/elibyy-tcpdf-laravel)[jimmyjs/laravel-report-generator

Rapidly Generate Simple Pdf &amp; Excel Report on Laravel 5 (Using Barryvdh/DomPdf or Barryvdh/laravel-snappy &amp; maatwebsite/excel)

580157.4k1](/packages/jimmyjs-laravel-report-generator)[stevebauman/autodoc-facades

Auto-generate PHP doc annotations for Laravel facades

98186.6k9](/packages/stevebauman-autodoc-facades)

PHPackages © 2026

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