#native_company# #native_desc#

Meet PRADO, the Component-based PHP Development Framework

By Octavia Andreea Anghel
on June 8, 2010

PRADO is a component-based and event-driven Web programming framework for PHP 5. A PRADO component represents a combination of a PHP class, an HTML template and a specification file (in XML). PRADO components are combined to form larger components or form complete PRADO pages.
Developing PRADO Web applications involves instantiating pre-built and application-specific component types, configuring them by setting their properties, responding to their events by writing handler functions, and composing them into application tasks.
PRADO provides the following benefits to Web application developers:
  • Reusability: Code that follows the PRADO component protocol is highly reusable. Everything in PRADO is a reusable component.
  • Ease of use: Creating and using components are extremely easy. Usually they simply involve configuring component properties.
  • Robustness: PRADO frees developers from writing boring, buggy code. They can code in terms of objects, methods and properties instead of URLs and query parameters. By exploiting the latest PHP5 exception mechanism, PRADO enables line-precise error reporting.
  • Performance: PRADO uses a cache technique to ensure the performance of applications based on it. A PRADO-based application’s performance is in fact comparable to that of applications based on common template engines.
  • Team integration: PRADO enables the separation of content and presentation. Components, typically pages, have their content (logic) and presentation stored in different files.
This article walks through the initial files and directories you will encounter when first using PRADO in your Web development.

Download and Install PRADO

You can download PRADO from the official website. You will also find very useful documentation in the documentation section.
Installing PRADO is very easy; all you need to do is unpack the PRADO release file to the prado subdirectory under the DocumentRoot of the Web server. With that, your installation of PRADO is done and you can start to play with the demo applications included in the PRADO release via the URL http://web-server-address/prado/demos/.
When you access the http://hostname/blog/index.php URL, you should see a web page showing “Welcome to PRADO”.

Intial Files for PRADO Development

The sections to follow discuss the intial files for PRADO Web application development.

The Entry Script

Every PRADO application has an entry script, often named index.php. In most applications index.php is the only PHP script that can be directly accessed by Web users. The main scope of the entry script is to initialize the PRADO application and have it handle user requests. A basic entry script can contain the following PHP statements:

// include prado.php which contains basic PRADO classes

// create a PRADO application instance
$application = new TApplication;

// run the application and handle user requests



The homepage (Home.page) is the only page created by the PRADO command-line tool. The content of this file appears in the browser when you access the http://hostname/blog/index.php URL. The content of Home.page uses the PRADO template format, which is like HTML enhanced with a few PRADO-specific tags.
The following are two examples of Home.page files, one containing pure HTML content and the other containing some basic PRADO components:
  1. Example 1:

      <title>Welcome to PRADO</title>
    <h1>Welcome to PRADO!</h1>

  2. Example 2:

    <label>Username:  </label>
    <com:TTextBox ID="username"/>
    <br />
    <label>Password:  </label> 
    <com:TTextBox ID="password" TextMode="Password" />
    <br />
    <com:TButton Text="Login" OnClick="buttonClicked" />

Application Configuration

You can set PRADO application configuration in the optional XML file application.xml. This file’s purpose is allow you to customize in a configurable fashion the application instance created in the entry script. For example, you may enable the logging feature for your blog system with the help of application configuration.
Here is an example of an application.xml file:

<?xml version="1.0" encoding="utf-8"?>
<application id="personal" mode="Normal">
    <using namespace="Application.Common.*" />
  <!-- modules configured and loaded for all services -->
    <!-- Remove this comment mark to enable logging
    <module id="log" class="System.Util.TLogRouter">
      <route class="TBrowserLogRoute" Categories="System" />
      <route class="TFileLogRoute" Categories="System" 
       Levels="Notice,Warning,Error,Alert,Fatal" />
    <!-- page service -->
    <service id="page" class="TPageService" BasePath="Application.Pages">
      <!-- modules configured and loaded when page service is requested -->
        <!-- user manager module -->
        <module id="users" class="System.Security.TUserManager" 
          <user name="demo" password="demo" />
        <!-- auth manager module -->
        <module id="auth" class="System.Security.TAuthManager" 
         UserManager="users" LoginPage="UserLogin" />