blob: ea6a2fba3f093924eb6e50864b9b02922e9f7391 [file] [log] [blame]
require_once( $_SERVER['DOCUMENT_ROOT'] . "birt/common/config.php");
$PagePart = new PagePart();
<!DOCTYPE html>
<html lang="en">
/* Set Page Level Meta Details */
$metaTitle = "Documentation";
$metaKeywords = "Eclipse,BIRT,Java,Java EE,Web,RCP,Data,Visualization,Reports,Reporting,Embed,Rich-Client,Dashboards";
$metaAuthor = "";
$metaDescription = "BIRT is an open source technology platform used to create data visualizations and reports that can be embedded into rich client and web applications.";
$ogTitle = "Eclipse BIRT Project Home";
$ogImage = "";
$ogDescription = "BIRT is an open source technology platform used to create data visualizations and reports that can be embedded into rich client and web applications.";
//only use following if you know what you are doing - else just leave them as is.
$robotsIndex = "index"; // ** *Only usable values are 'index', 'noindex'
$robotsFollow = "follow"; // ***Only usable values are 'follow', 'nofollow'
$canonicalTag = ""; //this is a canonical tag used for duplicate content *** DO NOT USE UNLESS YOU KNOW WHAT YOU ARE DOING *** Default is blank! ex:
# Generate Meta Info
echo $PagePart->getMetaInfo($metaTitle, $metaKeywords, $metaAuthor, $metaDescription, $ogTitle, $ogImage, $ogDescription, $robotsIndex, $robotsFollow, $canonicalTag);
<?php echo $PagePart->getAfterBody(); ?>
<div style="background-color:#f4f4f4;">
<div class="content-area">
<div class="content-area-inner" style="padding-top:40px;">
<div class="actu-eclipse-side-menu">
<?php echo $PagePart->getSideMenu(); ?>
<div class="dev-main eclipse-main">
<div class="eclipse-main-container">
<h1 class="eclipse-title-main">Using PHP</h1>
<div class="topic-menu topic-menu-right">
<div class="topic-menu-title">Section Contents</div>
<li><a href="/birt/documentation/install.php">Installation Guide</a></li>
<li><a href="/birt/documentation/tutorial/">Design Tutorial</a></li>
<li><a href="index.php">Integrating BIRT</a>
<li><a href="viewer-setup.php">Viewer Setup</a></li>
<li><a href="viewer-usage.php">Viewer Usage</a></li>
<li><a href="using-php.php">Using PHP</a></li>
<li><a href="scripting.php">Report Scripting</a></li>
<li><a href="deapi.php">Design Engine API</a></li>
<li><a href="reapi.php">Report Engine API</a></li>
<li><a href="/birt/documentation/sample-database.php">Sample Database</a></li>
<li><a href="/birt/documentation/reference.php">Technical Reference</a></li>
<li><a href="/birt/documentation/building-birt.php">Building BIRT</a></li>
<h2 class="topic-section-header padding-top-small">Motivation</h2>
<p>BIRT is designed to be integrated into a Java EE web application. But, what if your chosen development environment is something else, such as PHP? Can you still use BIRT? Yes, you can.&nbsp; This page discusses how to use BIRT from PHP.</p>
<h2 class="topic-section-header padding-top-small">Setup</h2>
<p>PHP has the ability to call Java classes using a PHP/Java Bridge. So, one integration option is to have the PHP engine call the BIRT Engine directly. The scenario is discussed in an article <a target="_blank" href="">here.</a> The examples associated with the article are posted <a href="">here.</a></p>
<p>Another option is to host BIRT on its own app server, such as Tomcat, and use the <a href="viewer-usage.php">BIRT Viewer URLs</a> to work with BIRT. The rest of this page discusses this option.</p>
<p>The first step is to <a href="viewer-setup.php">install Tomcat and the BIRT viewer</a>. Let's assume that you've set up Tomcat on the same machine as the web server running Apache, and that Tomcat listens on port 8080. Once the setup works, we're ready to focus on the PHP side.</p>
<h2 class="topic-section-header padding-top-small">Running a Report</h2>
<p>Next step is to run a report from within a PHP script. Let's assume we have a report named test.rptdesign stored in C:/temp. We use a browser redirect to run the report. The redirect appears in an HTML header. Headers must be written before adding any content to the page:</p>
$fname = "c:/temp/test.rptdesign";<br />
// Redirect browser<br />
$dest = "http://localhost:8080/birt-viewer/run?__report=";<br />
$dest .= urlencode( realpath( \$fname ) );<br />
header("Location: \$dest" );<br />
<p>The name of the report is given as an absolute path, but a relative path is also allowed once you set up the
configuration variable in the BIRT viewer web app's
<code>web.xml </code>
file. Be sure to encode the file name for use in a URL.</p>
<h2 class="topic-section-header padding-top-small">Passing Parameters</h2>
<p>Suppose your report takes parameters. The test report above has one parameter called <code>sample</code>. We simply add them to the report URL in the form described in <a href="viewer-usage.php">Using the Report Viewer</a>.</p>
$fname = "c:/temp/test.rptdesign";<br />
$paramValue = "Hi there!";<br />
// Redirect browser<br />
$dest = "http://localhost:8080/birt-viewer/run?__report=";<br />
$dest .= urlencode( realpath( \$fname ) );<br />
$dest .= ";sample=" . urlencode( \$paramValue );<br />
header("Location: \$dest" );<br />
<p>The parameter value must also be encoded when placed into the URL.</p>
<h2 class="topic-section-header padding-top-small">Parameter Form</h2>
<p>Ideally, we could use PHP to create a UI form that prompts for the report parameters. The BIRT viewer creates this form in Java using information in the report design. Unfortunately, at present, there is no way to retrieve the raw parameter descriptions from the BIRT viewer using a URL. Instead, there are two alternatives we can use.</p>
<p>First, if we know the parameters ahead of time, we can design a custom form in PHP that prompts the user for them. This works if we have a small number of reports, or if we need to create a specialized parameter page for each report anyway.</p>
<p>Second, we can let the BIRT viewer display the parameter page using the <code>frameset</code> URL.</p>
<?php echo $PagePart->getFooter(); ?>