PHPackages                             hasanhawary/report-builder - 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. hasanhawary/report-builder

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

hasanhawary/report-builder
==========================

A modular Laravel report builder for cards, charts, and tables.

v1.2.1(5mo ago)0238↓33.3%1MITPHPPHP &gt;8.0

Since Sep 21Pushed 5mo agoCompare

[ Source](https://github.com/hasanhawary/report-builder)[ Packagist](https://packagist.org/packages/hasanhawary/report-builder)[ Docs](https://github.com/hasanhawary/report-builder)[ RSS](/packages/hasanhawary-report-builder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

Laravel Report Builder
======================

[](#laravel-report-builder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/96cded1861683ae4d5178494d1a80e1729e0de4cc43477d1e1426f8dfed7acf6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686173616e6861776172792f7265706f72742d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hasanhawary/report-builder)[![Total Downloads](https://camo.githubusercontent.com/79f79e7c6d2ee1cb7499cee34a65b5f0deb3928a20c56c8eff2317b5ff116077/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686173616e6861776172792f7265706f72742d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hasanhawary/report-builder)[![License](https://camo.githubusercontent.com/f7f8fb1ce0989559dba5e1e868289ec771f19dffed9176e03007e0e0b8f8cb36/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f686173616e6861776172792f7265706f72742d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A flexible **report builder for Laravel** that helps you generate **cards, charts, and tables** from your data models with minimal effort.
Easily configurable via `config/report.php`, with support for **HighCharts**, **dynamic filters**, and **multiple report pages**.

---

🚀 Features
----------

[](#-features)

- 🔹 Generate **cards**, **charts**, and **tables** with unified structure.
- 🔹 Out-of-the-box support for **HighCharts**.
- 🔹 Simple configuration using `config/report.php`.
- 🔹 Build multiple report pages (`users`, `orders`, etc.).
- 🔹 Extendable via your own Report classes.
- 🔹 JSON response format ready for any frontend (Vue, React, Inertia, Livewire...).

---

📦 Installation
--------------

[](#-installation)

```
composer require hasanhawary/report-builder
```

Optionally publish config file:

```
php artisan vendor:publish --tag=report-config
```

---

⚙️ Configuration
----------------

[](#️-configuration)

Your reports are defined in **`config/report.php`**:

```
return [
    'namespace' => 'App\\Reports',

    'pages' => [
        'users' => [
            'report' => [
                'by_status' => ['type' => 'chart'],
                'summary'   => ['type' => 'card'],
            ],
        ],
    ],
];
```

- `namespace` → location of your custom report classes.
- `pages` → defines available reports per page.

---

🛠 Usage
-------

[](#-usage)

### Create a Report

[](#create-a-report)

Create `App/Reports/UserReport.php`:

```
namespace App\Reports;

use HasanHawary\ReportBuilder\BaseReport;
use Illuminate\Support\Facades\DB;

class UserReport extends BaseReport
{
    public string $table = 'users';

    public function getByStatus(): array
    {
        $data = DB::table($this->table)
            ->selectRaw('status, COUNT(*) as count')
            ->groupBy('status')
            ->get();

        return $this->chartResponse('status', $data, 'pie');
    }

    public function getSummary(): array
    {
        $data = [
            ['name' => 'Total Users', 'value' => DB::table($this->table)->count()],
            ['name' => 'Active Users', 'value' => DB::table($this->table)->where('status', 'active')->count()],
        ];

        return $this->cardResponse($data);
    }
}
```

---

### Call from Controller or Route

[](#call-from-controller-or-route)

```
use HasanHawary\ReportBuilder\ReportBuilder;

Route::get('/reports/users', function () {
    return (new ReportBuilder([
        'page' => 'users',
        'types' => 'all',
        'prefer_chart' => 'bar',
    ]))->response();
});
```

---

### Example Response

[](#example-response)

```
{
  "report": {
    "title": "users_report",
    "page": "users",
    "cards": {
      "type": "card",
      "size": {
        "cols": "6",
        "md": "3",
        "lg": "3"
      },
      "title": "cards",
      "data": [
        {
          "key": "total_users",
          "value": 200,
          "label": "Total Users",
          "size": {
            "cols": "6",
            "md": "3",
            "lg": "3"
          }
        },
        {
          "key": "active_users",
          "value": 150,
          "label": "Active Users",
          "size": {
            "cols": "6",
            "md": "3",
            "lg": "3"
          }
        }
      ]
    },
    "tables": [
      {
        "type": "table",
        "size": {
          "cols": "12",
          "md": "12",
          "lg": "12"
        },
        "title": "Users by Status",
        "data": [
          {
            "status": "active",
            "count": 10
          },
          {
            "status": "inactive",
            "count": 5
          }
        ],
        "columns": [
          {
            "title": "Status",
            "key": "status"
          },
          {
            "title": "Count",
            "key": "count"
          }
        ]
      }
    ],
    "charts": [
      {
        "type": "bar",
        "size": {
          "cols": "12",
          "md": "6",
          "lg": "6"
        },
        "title": "Users Activity",
        "data": {
          "bar": {
            "chart": {
              "type": "bar",
              "style": {
                "fontFamily": "Cairo , Poppins, sans-serif"
              }
            },
            "xAxis": {
              "categories": ["active", "inactive"]
            },
            "yAxis": {
              "title": {
                "text": "Users"
              }
            },
            "series": [
              {
                "name": "count",
                "data": [10, 5],
                "color": "rgba(var(--v-theme-primary),1)"
              }
            ]
          }
        }
      }
    ]
  },
  "filter": {
    "page": "users",
    "types": "all",
    "prefer_chart": "bar"
  }
}
```

---

📊 Available Response Helpers
----------------------------

[](#-available-response-helpers)

Inside your Report classes you can use:

```
$this->cardResponse($data);  // Computable to render as a card
$this->chartResponse('field', $data, 'bar'); // All types returned by default
$this->chartResponse('field', $data, 'bar');
$this->chartResponse('field', $data, 'pie');
$this->chartResponse('field', $data, 'line');
$this->chartResponse('field', $data, 'table');
```

---

🔧 Advanced Usage
----------------

[](#-advanced-usage)

- **Multiple Pages** → define `orders`, `sales`, `products` inside `config/report.php`.
- **Mixed Reports** → pass `types=['summary','by_status']` to `ReportBuilder` for custom dashboards.
- **Custom Chart Types** → set `prefer_chart = 'pie' | 'bar' | 'line'`.

---

🎨 Demo Frontend Integration
---------------------------

[](#-demo-frontend-integration)

The JSON response is **frontend-agnostic**. You can render it in **Vue**, **React**, or **any JS chart library**.

Usage / Examples
----------------

[](#usage--examples)

### Vue 3 + Highcharts

[](#vue-3--highcharts)

```

import Highcharts from "highcharts";
import HighchartsVue from "highcharts-vue";
import { ref, onMounted } from "vue";

const chartOptions = ref(null);

onMounted(async () => {
  const response = await fetch("reports?page=users");
  const data = await response.json();
  chartOptions.value = data.report.charts[0].data[data.report.charts[0].type];
});

```

---

### React + Highcharts

[](#react--highcharts)

```
import React, { useEffect, useState } from "react";
import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";

export default function UserReport() {
  const [options, setOptions] = useState(null);

  useEffect(() => {
    fetch("/reports?page=users")
      .then(res => res.json())
      .then(data => {
        const chart = data.report.charts[0];
        setOptions(chart.data[chart.type]);
      });
  }, []);

  return options ?  : null;
}
```

---

### Vanilla JS + Highcharts

[](#vanilla-js--highcharts)

```
>

  Report Example

    fetch("/reports?page=users")
      .then(res => res.json())
      .then(data => {
        const chart = data.report.charts[0];
        const options = chart.data[chart.type];
        Highcharts.chart("container", options);
      });

```

---

🤝 Contributing
--------------

[](#-contributing)

Pull requests are welcome! For major changes, please open an issue first to discuss what you’d like to change. Make sure to update tests as appropriate.

---

✅ Version Support
-----------------

[](#-version-support)

- **PHP**: 8.0 – 8.5
- **Laravel**: 8 – 12

---

📜 License
---------

[](#-license)

MIT © [Hasan Hawary](https://github.com/hasanhawary)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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 ~14 days

Total

7

Last Release

153d ago

PHP version history (2 changes)v1.0.0PHP ^8.0

v1.0.1PHP &gt;8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33836947?v=4)[Hassan Elhawary](/maintainers/hasanhawary)[@hasanhawary](https://github.com/hasanhawary)

---

Top Contributors

[![hasanhawary](https://avatars.githubusercontent.com/u/33836947?v=4)](https://github.com/hasanhawary "hasanhawary (9 commits)")

---

Tags

laravelreportdashboardanalyticschartstablesreports

### Embed Badge

![Health badge](/badges/hasanhawary-report-builder/health.svg)

```
[![Health](https://phpackages.com/badges/hasanhawary-report-builder/health.svg)](https://phpackages.com/packages/hasanhawary-report-builder)
```

###  Alternatives

[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)[ghanem/reportable

Reportable Polymorphic Eloquent Models for Laravel 6, 7, 8, 9, 10, 11 &amp; 12

347.6k](/packages/ghanem-reportable)[samuelterra22/laravel-report-generator

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

125.3k](/packages/samuelterra22-laravel-report-generator)

PHPackages © 2026

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