My First PRADO Application

In this section, we guide you through creating your first PRADO application, the famous "Hello World" application.

"Hello World" perhaps is the simplest interactive PRADO application that you can create. It displays to end-users a page with a submit button whose caption is Click Me. After the user clicks on the button, its caption is changed to Hello World.

There are many approaches that can achieve the above goal. One can submit the page to the server, examine the POST variable, and generate a new page with the button caption updated. Or one can simply use JavaScript to update the button caption upon its onclick client event.

PRADO promotes component-based and event-driven Web programming. The button is represented by a TButton object. It encapsulates the button caption as the Text property and associates the user button click action with a server-side OnClick event. To respond to the user clicking on the button, one simply needs to attach a function to the button's OnClick event. Within the function, the button's Text property is modified as "Hello World". The following diagram shows the above sequence,

Our PRADO application consists of three files, index.php, Home.page and Home.php, which are organized as follows, where each directory is explained as follows. Note, the above directory structure can be customized. For example, one can move the protected directory out of Web directories. You will know how to do this after you go through this tutorial.

Tip:You may also use the bin/prado-cli.php (framework/prado-cli.php for Prado < 3.2.3) command line script to create the Prado project directory structure. For example, type the command php path/to/prado-cli.php -c helloworld in the directory where you want to create the helloworld project.

The three files that we need are explained as follows.

The application is now ready and can be accessed via: http://Web-server-address/helloworld/index.php, assuming helloworld is directly under the Web DocumentRoot. Try to change TButton in Home.page to TLinkButton and see what happens.

Complete source code of this demo can be found in the PRADO release. You can also try the online demo.