nexterp / jasper-reports
A Jasper Reports bridge for Laravel with Java 8 compatibility and pre-compiled templates.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:Roff
pkg:composer/nexterp/jasper-reports
Requires
- php: >=8.1
- geekcom/phpjasper: ^3.0
This package is not auto-updated.
Last update: 2026-02-01 14:19:50 UTC
README
A robust, enterprise-grade wrapper for Jasper Reports in Laravel, designed to seamlessly handle Java compatibility issues on modern systems (macOS Apple Silicon, Linux, etc.) by enforcing the use of Java 8.
🚀 Features
- Java 8 Compatibility Engine: Solves $ClassCastException$ issues by using a strictly defined local Java 8 binary.
-
Automated Binary Patching: Automatically patches the underlying
jasperstarterexecutable to use the local Java 8. - Enterprise Reports: Includes pre-built templates for Trial Balance, Income Statement, Balance Sheet, Cash Flow, Changes in Equity, and General Ledger.
🛠Step-by-Step Installation
Follow these steps to integrate Jasper Reports into your Laravel project.
1. Install Package
You can install this package via Packagist (recommended) or directly from GitHub.
Option A: via Packagist (Standard)
Run the following command:
composer require nexterp/jasper-reports
Option B: via GitHub (Direct)
Add the repository to your root composer.json:
"repositories": [ { "type": "vcs", "url": "https://github.com/tinashekadiki/erp-reports.git" } ],
Then run:
composer require nexterp/jasper-reports:dev-main
2. Auto-Update Setup (GitHub Hook)
To ensure the package on Packagist stays in sync with your GitHub repository, set up the GitHub Hook for Packagist:
- Go to your GitHub repository -> Settings -> Webhooks.
- Click Add webhook.
- Payload URL:
https://packagist.org/api/github?username=tinashekadiki - Content type:
application/json - Secret: Your Packagist API Token
- Select "Just the push event" and click Add webhook.
3. Run Automated Setup
This package includes a setup script that automates Java 8 installation and binary patching for macOS and Linux.
# Navigate to the package directory (or run from root if scripts are synced) cd vendor/nexterp/jasper-reports chmod +x setup-jasper.sh ./setup-jasper.sh
Note: Default setup password is nexterp123.
4. Publish Resources
Publish the report templates and views to your application:
php artisan vendor:publish --tag=jasper-reports-templates
5. Finalize Environment
Ensure your root post-update-cmd.php (if present) or composer.json scripts are configured to run patching on every dump-autoload. If you encounter Java errors, run:
composer dump-autoload
6. Rebuilding Reports
If you modify the report templates (.jrxml files), you must recompile them to update the binary .jasper files. Use the provided rebuild script:
php rebuild_all_v3.php
This will scan the report directory and recompile all templates to ensure your changes are reflected in the generated output.
💻 Usage
Generating a Report
Inject JasperReportService into your controller:
use Nexterp\JasperReports\JasperReportService; public function __construct(JasperReportService $jasper) { $this->jasper = $jasper; } public function download() { $input = resource_path('reports/vendor/jasper-reports/trial_balance.jrxml'); $output = storage_path('app/reports/trial_balance_'.time()); $params = ['logo' => public_path('logo.png')]; $path = $this->jasper->generateReport($input, $output, ['pdf'], $params); return response()->file($path); }
📊 Included Reports
- Trial Balance:
trial_balance.jrxml - Income Statement:
income_statement.jrxml - Balance Sheet:
balance_sheet.jrxml - Cash Flow:
cash_flow.jrxml - Changes in Equity:
changes_in_equity.jrxml - General Ledger:
general_ledger.jrxml
🔧 Troubleshooting
| Error | Cause | Solution |
|---|---|---|
ClassCastException |
System Java (17+) is used. | Run composer dump-autoload to re-patch. |
Logo not found |
Invalid image path. | Use absolute paths via public_path() or resource_path(). |
Permission denied |
Script lacks execution bits. | Run chmod +x setup-jasper.sh. |
📜 License
MIT