Getting started with the Smart Report Engine Community Edition is incredibly easy. To directly download the community edition of Smart Report Engine Please use the link below.
Download The Community Edition
If you're using Composer, you have the alternative option of employing the following Composer command:
composer create-project webuccinoco/sre-community
├── SmartReportingEngine/
├── sre_config/
└── config.php
├── sre_reports/
├── db/
└── example.sql
├── examples/
└── sre_bootstrap.php
In the Community Edition's "/examples" directory, you'll find three helpful examples to get you started with Smart Report Engine. To execute any of these examples, just access their URLs from your web browser. This will enable you to view the generated report based on the code in each example. Should you prefer to build the example projects from scratch, kindly proceed with the next step of the installation process.Regardless of your choice, the code walkthrough sections will provide explanations for the code in each example.
To begin writing your first project, you'll require a new PHP script. For the purpose of this tutorial, you can add the script to the root directory of the community edition, alongside the "sre_bootstrap.php" file. If you've obtained the community edition through manual download (without utilizing Composer), you'll have to include the autoload file "sre_bootstrap.php" in your code, as shown in the example below. Conversely, if Composer has been employed, you'll have to include the Composer autoloader file "vendor/autoload.php". It's important to consider that if your code resides in a location other than the root directory, you must appropriately modify the path to the autoload file. Please follow these steps to get started with your project:
use SRE\Engine\CustomEngine;
use SRE\Engine\ReportOptions;
require_once "sre_bootstrap.php"; //require 'vendor/autoload.php' incase of using composer
try {
$report = new ReportOptions();
$report->select_tables("items")
->set_grouping("country")
->set_title("Items Per country")
->select_all_fields();
$engine = new CustomEngine($report);
$report_path = $engine->create_report();
if ($report_path) {
// The user will be redirected to the URL of the generated report. All generated reports are stored as subdirectories under /sre_reports.
header("location: ".$report_path);
exit();
}
} catch (Exception $e) {
echo $e->getMessage();
}
The given code demonstrates a basic example of using Smart Report Engine effectively. Let's walk through the code step by step to understand how it functions:
use SRE\Engine\CustomEngine;
use SRE\Engine\ReportOptions;
require_once "sre_bootstrap.php";
try {
$report = new ReportOptions();
$report->select_tables("items")
->set_grouping("country")
->sort_by("country", 1)
->filter_like("category", "sunglasses")
->filter_between("price", 15, 50)
->filter_more("rating", 3.5)
->filter_not_null("code")
->set_title("Using data filters")
->select_fields(array("id","code","name","price","reorder_level","units_in_stock","category","country","rating"));
$engine = new CustomEngine($report);
$report_path = $engine->create_report();
if ($report_path) {
// The user will be redirected to the URL of the generated report. All generated reports are stored as subdirectories under /sre_reports.
header("location: ".$report_path);
exit();
}
} catch (Exception $e) {
echo $e->getMessage();
}
In the code example provided earlier, we applied additional methods to the "items" table, enabling us to achieve the following:
use SRE\Engine\CustomEngine;
use SRE\Engine\ReportOptions;
require_once "sre_bootstrap.php";
try {
$report = new ReportOptions();
$report->select_tables("items")
->set_grouping(array("category","country"))
->sort_by("category",1)
->filter_between("price", 15, 50)
->filter_more("rating", 3.5)
->filter_not_null("code")
->set_filters_grouping("or")
->set_chkSearch(false)
->select_fields(array("id","code","name","price","reorder_level","units_in_stock","category","country","rating"))
->set_style_name("grey")
->set_records_per_page(25)
->set_language("es")
->set_title("Items Per category")
->set_header("Here is some HTML code that you can use to customize the header of the report.");
$engine = new CustomEngine($report);
$report_path = $engine->create_report();
if ($report_path) {
// The user will be redirected to the URL of the generated report. All generated reports are stored as subdirectories under /sre_reports.
header("location: ".$report_path);
exit();
}
} catch (Exception $e) {
echo $e->getMessage();
}
In the previously provided code example, we demonstrated a two-level grouping, showcasing Smart Report Engine's ability to support multiple grouping levels. Additionally, we modified the data filters to be grouped using the "or" logic.
Moreover, we performed some appearance customization by changing the report theme and changing the report interface language. This is especially useful if the report data is in a language other than English, as it allows the report interface to align with the data language. Smart Report Engine supports English, French, Spanish, German, Arabic, and Italian by default and other languages could be easily added.
Furthermore, we enhanced the report's presentation by adding a title, header, and footer sections. Additionally, we changed the default number of records displayed per page for better usability.
Lastly, we disabled the ordinary and advanced search features for this particular generated report, tailoring the report's functionalities to specific requirements.
Please note that By using any of our commercial editions you are granted access to all premium features, as well as the removal of all community restrictions mentioned above.