Download the PHP package rctnet/jasperphp without Composer
On this page you can find all versions of the php package rctnet/jasperphp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rctnet/jasperphp
More information about rctnet/jasperphp
Files in rctnet/jasperphp
Package jasperphp
Short Description Pure PHP library to read JRXML files made with 'JasperSoft Studio' and generate reports in PDF
License MIT
Informations about the package jasperphp

JasperPHP
A pure PHP library to generate reports from JasperSoft Studio (.jrxml files), without the need for a Java bridge or a Jasper Server.
For more details, documentation, and blog posts, visit jasperphp.com.
Recent Changes & Modernization
This project has undergone a significant modernization effort to align with current PHP best practices. Key changes include:
- Laravel\Octane integration: Added methods to reset static classes and values to each request (tested OK)
- Composer Integration: The project now uses Composer for dependency management.
- PSR-4 Autoloading: Switched to PSR-4 for class autoloading, with a reorganized and namespaced directory structure (
src/). - Static Analysis:
phpstanhas been integrated to improve code quality and catch errors. - Flexible Data Sources: Added support for multiple data sources, including Arrays, JSON/CSV files, and direct database queries.
- Versatile Output Methods: Introduced new methods to stream reports to the browser, force downloads, save to a file, or get the content as a base64 string.
Requirements
- PHP 7.4 or higher
- Composer for dependency management.
The following PHP extensions are also required:
gdmbstringxml
Installation
Install the library using Composer:
Quick Start
Here is a basic example of how to generate a report. For a more detailed and runnable example, see public/index.php.
Data Sources
You can use different types of data sources to populate your reports.
Array
Pass an array of objects or associative arrays directly.
Database (DB)
Execute a SQL query to fetch data.
JSON or CSV File
Load data from a local .json or .csv file.
Using Embedded SQL Query (from JRXML)
The library also retains the classic JasperReports functionality of executing a SQL query embedded directly within the .jrxml file. When no dataSource is provided in the PHP code, JasperPHP will look for a <queryString> tag inside the report file and execute it using the provided database connection.
This method is especially useful for creating master-detail reports, where a subreport can fetch its own data based on parameters passed from the main report.
Example JRXML (subreport.jrxml):
Example PHP:
To run a report with an embedded query, provide the database connection details but omit the 'sql' key from the dataSource.
Output Methods
The output() method provides several ways to deliver the generated report.
$mode:I(Inline): Streams the report directly to the browser. (Default)D(Download): Forces the browser to download the report file.F(File): Saves the report to a local file specified by$filePath.S(String): Returns the raw report content as a string (or base64 encoded for binary formats).
$filename: The name of the file forIandDmodes.$filePath: The absolute path to save the file inFmode.
Examples:
Supported Formats
- XLS
- XLSX
Supported JRXML Elements
The library supports a wide range of JRXML tags and components.
| TAG/Component | Status | TAG/Component | Status |
|---|---|---|---|
| Basic Elements | |||
| Text Field | OK | Static Text | OK |
| Image | OK | Break | OK |
| Rectangle | OK | Line | OK |
| SubReport* | OK | Barcode | OK |
| Composite Elements | |||
| Page Number | OK | Total Pages | OK |
| Current Date | OK | Page X of Y | OK |
| Bands | |||
| Title | OK | Page Header | OK |
| Group | OK | Detail | OK |
| Column Header | OK | Column Footer | OK |
| Page Footer | OK | Summary | OK |
| Background | OK | Style | OK |
| Frame | OK | Dynamic Table | OK |
* Subreports are supported recursively and without limits.
Other Features
- Aggregation functions for variables (sum, average, min, max).
- Reading and calculating variables from subreports.
- Conditional styling.
- Support for Laravel DB Facade by setting the
net.sf.jasperreports.data.adapterproperty in your JRXML.
License
This library is licensed under the MIT License.