PHPackages                             lss/yareport - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lss/yareport

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lss/yareport
============

Yet Another Report Writer

09PHP

Since Jan 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/pavarnos/yareport)[ Packagist](https://packagist.org/packages/lss/yareport)[ RSS](/packages/lss-yareport/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Yet Another Report Writer
-------------------------

[](#yet-another-report-writer)

A report writer where you

- define the columns you want
- get data from somewhere (eg a database query)
- render the data in different formats eg json, csv, html, or extract email addresses

This is based on a library i first wrote in the late 1990s. I have used it in many projects since then, and kept it up to date as PHP has matured

- PHP &gt;= 8.0 with strict types
- phpstan --level=max
- high unit test coverage
- battle tested over many years
- as lightweight as possible internally

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

[](#installation)

```
composer require lss/yareport

```

See also `lss/yadbal`, a database abstraction layer which plays nice with this. You need a bit of extra glue code (see the examples folder)

Usage
-----

[](#usage)

Create a report

```
$report = new Report();
$report->addColumn((new Column('name', 'Name', 'Personal name'))->setSortOrder(['name']));
$report->addColumn((new EmailColumn('email', 'Email'))->setSortOrder(['email']));
$report->addColumn((new MoneyColumn('rate', 'Hourly Rate'))->setCurrencySymbol('$')->setSortOrder(['rate', 'name']));
$report->addColumn(new IntegerColumn('weight', 'Weight (kg)', 'before eating'));
$report->addColumn((new BooleanColumn('is_active', 'Is Active'))->setNoHtml('Nope')->setYesHtml('Yep'));
$report->addColumn((new CalculatedColumn('menu', ''))->setRenderHtml(fn() => '*menu*'));
```

Then render it in multiple formats

Comma Separated Values

```
$csvString = (new CSVRender())->render($report, $data);
return new Response(200, ['Content-Type' => 'text/csv'], $csvString);
```

JSON

```
$jsonArray = (new JsonRender())->render($report, $data);
return new Response(200, ['Content-Type' => 'text/json'], json_encode($jsonArray));
```

Email

```
$emailAddresses = (new EmailRender())->render($report, $data, fn(array $row): string => $row['name'] ?? '');
// eg as a response to an ajax request
return new Response(200, ['Content-Type' => 'text/plain'], join(', ', $emailAddresses));
```

Per-User customisation
----------------------

[](#per-user-customisation)

Columns can be required, visible or hidden. The `ReportSerializer` allows you to define a standard report with default columns that everyone sees. If you create a way to customise the report (add extra optional columns, change the order of columns, change titles etc), the `ReportSerializer` allows you to save this somewhere per user and then re-load it so the user sees their version of the report based on the standard template. The serializer is robust so if you add or delete columns from the code and the per-user configuration refers to old columns, they will be silently ignored

Tips
----

[](#tips)

You probably want all `MoneyColumn`s to be configured the same way. And other column types too. Make a `ReportBuilder`or `ColumnFactory` class that creates and configures each column type just as you want. eg I have a `BulkActionsCheckbox` column type that adds checkboxes down the left side of the html table, and a `MenuColumn` that goes on the right side of an html table. I use these in a lot of places and don't want to repeat myself

The classes are designed to be easy to extend with msny protected methods. I make no promises about maintaining backwards compatibility for protected methods, but if anything changes it should be a fairly painless migration (because i will also have to make the same migrations in all my code). Changes are unlikely. I've used this library for many years and it is fairly stable now. Major internal changes or changes of the public interface will follow semver.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

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://www.gravatar.com/avatar/6b01be5b996fa22f6e49ed9a1d3c55c44b883de66e4ee6ec8acdc4b51fc3697f?d=identicon)[pavarnos](/maintainers/pavarnos)

---

Top Contributors

[![pavarnos](https://avatars.githubusercontent.com/u/589595?v=4)](https://github.com/pavarnos "pavarnos (8 commits)")

### Embed Badge

![Health badge](/badges/lss-yareport/health.svg)

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

###  Alternatives

[liaison/revision

Seamless software updates library for CodeIgniter4 projects.

186.4k1](/packages/liaison-revision)

PHPackages © 2026

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