Initial Directories for PRADO Application Setup
The sections to follow discuss the intial directories for setting up a PRADO application.
The Protected Directory
protecteddirectory, also known as the application base path, is the root directory for holding pages, templates, configurations, data, etc. As its name indicates, the
protecteddirectory should be hidden from Web users, because files under this directory often contain sensitive data. Different Web servers have different ways of “protecting” a directory. For Apache httpd server, the easiest way is to place a file named
.htaccesswith the content
deny from allunder the directory.
The Protected/Runtime and Assets Directories
assetsdirectories are the two directories that must be set to “writable” by the Web server process. The
runtimedirectory stores sensitive data (e.g., parsed application configuration) generated when running a PRADO application, while the
The Pages Directory
pagesdirectory is the root page directory holding all pages in a PRADO application. It is similar to the
htdocsdirectory for the Apache httpd Web server. To access an arbitrary page located under
pages, you can use the
http://hostname/application/index.php?page=path.to.PageNameURL. According to this URL, PRADO will look for a page named “PageName” under the directory
pages/path/to. The URL you previously used to access the homepage is equivalent to
Customization of Initial Files and Directories
You can customize the name and location of the files and directories described in the previous two sections. For example, to improve security, you could move the whole
protecteddirectory to somewhere else that is not a Web folder. To do so, use the following PHP statement to create the application instance in the entry script:
$application = new TApplication( 'path/to/protected' );
To change the location of the root page directory and change the name of homepage, you can specify it in the application configuration file
<?xml version="1.0" encoding="utf-8"?> <application id="blog" mode="Debug"> <services> <service id="page" class="TPageService" BasePath="path.to.pages" DefaultPage="NewHome" /> </services> </application>
As you learn more about PRADO, you will see that PRADO is such a flexible framework that you can customize nearly every aspect. For example, Figure 1 presents a class tree with some of the major classes provided by PRADO.
Click here for larger image
Figure 1. The Class Tree Scheme and the Main Classes Provided by PRADO
This article introduced the PRADO framework and presented the basics for beginning to build applications using it. The next article will build on this knowledge and demonstrate how to implement custom components into your PHP applications using PRADO.
About the Author
Octavia Andreea Anghel is a senior PHP developer currently working as a primary trainer for programming teams that participate at national and international software-development contests. She consults on developing educational projects at a national level. She is a coauthor of the book “XML Technologies — XML in Java” (Albastra, ISBN 978-973-650-210-1), for which she wrote the XML portions. In addition to PHP and XML, she’s interested in software architecture, web services, UML, and high-performance unit tests. to e-mail her.