| 1 |
lars |
1 |
<com:TContent ID="body" >
|
|
|
2 |
|
|
|
3 |
<h1 id="1201">Applications</h1>
|
|
|
4 |
<p id="160157" class="block-content">
|
|
|
5 |
An application is an instance of <tt>TApplication</tt> or its derived class. It manages modules that provide different functionalities and are loaded when needed. It provides services to end-users. It is the central place to store various parameters used in an application. In a PRADO application, the application instance is the only object that is globally accessible via <tt>Prado::getApplication()</tt> function call.
|
|
|
6 |
</p>
|
|
|
7 |
<p id="160158" class="block-content">
|
|
|
8 |
Applications are configured via <a href="?page=Configurations.AppConfig">application configurations</a>. They are usually created in entry scripts like the following,
|
|
|
9 |
<com:TTextHighlighter CssClass="source block-content" id="code_160071">
|
|
|
10 |
require_once('/path/to/prado.php');
|
|
|
11 |
$application = new TApplication;
|
|
|
12 |
$application->run();
|
|
|
13 |
</com:TTextHighlighter>
|
|
|
14 |
where the method <tt>run()</tt> starts the application to handle user requests.
|
|
|
15 |
</p>
|
|
|
16 |
|
|
|
17 |
<h2 id="1202">Directory Organization</h2>
|
|
|
18 |
<p id="160159" class="block-content">
|
|
|
19 |
A minimal PRADO application contains two files: an entry file and a page template file. They must be organized as follows,
|
|
|
20 |
<img src="<%~directory.gif%>" class="figure"/>
|
|
|
21 |
</p>
|
|
|
22 |
<ul id="u2" class="block-content">
|
|
|
23 |
<li><tt>wwwroot</tt> - Web document root or sub-directory.</li>
|
|
|
24 |
<li><tt>index.php</tt> - entry script of the PRADO application.</li>
|
|
|
25 |
<li><tt>assets</tt> - directory storing published private files. See <a href="?page=Advanced.Assets">assets</a> section.</li>
|
|
|
26 |
<li><tt>protected</tt> - application base path storing application data and private script files. This directory should be configured inaccessible to Web-inaccessible, or it may be located outside of Web directories.</li>
|
|
|
27 |
<li><tt>runtime</tt> - application runtime storage path. This directory is used by PRADO to store application runtime information, such as application state, cached data, etc.</li>
|
|
|
28 |
<li><tt>pages</tt> - base path storing all PRADO pages. See <a href="?page=Fundamentals.Services">services</a> section.</li>
|
|
|
29 |
<li><tt>Home.page</tt> - default page returned when users do not explicitly specify the page requested. This is a page template file. The file name without suffix is the page name. The page class is <tt>TPage</tt>. If there is also a class file <tt>Home.php</tt>, the page class becomes <tt>Home</tt>.</li>
|
|
|
30 |
</ul>
|
|
|
31 |
|
|
|
32 |
<p id="160160" class="block-content">
|
|
|
33 |
A product PRADO application usually needs more files. It may include an application configuration file named <tt>application.xml</tt> under the application base path <tt>protected</tt>. The pages may be organized in directories, some of which may contain page configuration files named <tt>config.xml</tt>. Fore more details, please see <a href="?page=Configurations.Overview">configurations</a> section.
|
|
|
34 |
</p>
|
|
|
35 |
|
|
|
36 |
<h2 id="1203">Application Deployment</h2>
|
|
|
37 |
<p id="160161" class="block-content">
|
|
|
38 |
Deploying a PRADO application mainly involves copying directories. For example, to deploy the above minimal application to another server, follow the following steps,
|
|
|
39 |
</p>
|
|
|
40 |
<ol>
|
|
|
41 |
<li>Copy the content under <tt>wwwroot</tt> to a Web-accessible directory on the new server.</li>
|
|
|
42 |
<li>Modify the entry script file <tt>index.php</tt> so that it includes correctly the <tt>prado.php</tt> file.</li>
|
|
|
43 |
<li>Remove all content under <tt>assets</tt> and <tt>runtime</tt> directories and make sure both directories are writable by the Web server process.</li>
|
|
|
44 |
</ol>
|
|
|
45 |
|
|
|
46 |
<h2 id="1204">Application Lifecycles</h2>
|
|
|
47 |
<p id="160162" class="block-content">
|
|
|
48 |
Like page lifecycles, an application also has lifecycles. Application modules can register for the lifecycle events. When the application reaches a particular lifecycle and raises the corresponding event, the registered module methods are invoked automatically. Modules included in the PRADO release, such as <tt>TAuthManager</tt>, are using this way to accomplish their goals.
|
|
|
49 |
</p>
|
|
|
50 |
<p id="160163" class="block-content">
|
|
|
51 |
The application lifecycles can be depicted as follows,
|
|
|
52 |
</p>
|
|
|
53 |
<img src="<%~applifecycles.gif%>" />
|
|
|
54 |
|
|
|
55 |
<div class="last-modified">$Id: Applications.page 1650 2007-01-24 06:55:32Z wei $</div></com:TContent>
|