Rendering a Report from Code on the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.Reports.PHP can render reports fully on the server using an embedded Node.js engine, with no browser involved.
Code overview. Initialize the required report objects, render a report from code on the server-side, and handle the resulting state or output.
Setting
Code overview. Initialize the required report objects, render a report from code on the server-side, and handle the resulting state or output.
$report = new StiReport();
$report->engine = StiEngineType::ServerNodeJS;
$report->process();
$report->loadFile('reports/SimpleList.mrt', true);
$result = $report->render();
if ($result)
$document = $report->saveDocument();
else
$message = $report->nodejs->error;engine = StiEngineType::ServerNodeJS— switches rendering to the embedded Node.js engine, so it runs entirely on the server.loadFile('...', true)— loads the template for server-side rendering.render()— renders the report on the server and returns success or failure.saveDocument()— returns the rendered document;nodejs->errorholds any engine error.
Setting
engine = StiEngineType::ServerNodeJS runs the rendering in Node.js on the server; saveDocument() returns the rendered document. This is the basis for scheduled or headless report generation.