Commit caf9edc2 by Larry Ullman

Edited

Lovely!
parent 3a4c581d
Running Applications
====================
You now have a working Yii application which can be accessed via URL `http://hostname/index.php`.
In this section, we will introduce what functionalities this application has, how the code is organized,
After installing Yii, you have a working Yii application that can be accessed via the URL `http://hostname/basic/web/index.php` or `http://hostname/index.php`, depending upon your configuration. This section will introduce the application's built-in fucntionality, how the code is organized,
and how the application handles requests in general.
> Info: For simplicity, throughout this "Getting Started" tutorial we assume that you have set `basic/web`
as the document root of your Web server. If you have not done so, the URL for accessing
your application could be `http://hostname/basic/web/index.php`, or something similar.
Please adjust the URLs accordingly in our descriptions.
> Info: For simplicity, throughout this "Getting Started" tutorial, it's assumed that you have set `basic/web`
as the document root of your Web server, and configured, the URL for accessing
your application to be `http://hostname/index.php` or something similar.
For your needs, please adjust the URLs in our descriptions accordingly.
Functionalities <a name="functionalities"></a>
Functionality <a name="functionality"></a>
---------------
The application that you have installed contains four pages:
The basic application installed contains four pages:
* the homepage is the page displayed when you access the URL `http://hostname/index.php`;
* the "About" page;
* the "Contact" page displays a contact form that allows end users to contact you by filling out the form;
* the homepage, displayed when you access the URL `http://hostname/index.php`
* the "About" page
* the "Contact" page displays a contact form that allows end users to contact you via email
* the "Login" page displays a login form that can be used to authenticate end users. Try logging in
with "admin/admin", and you will find the "Login" main menu item will change to "Logout".
These pages share a common header and footer. The header contains a main menu bar to allow navigate
These pages share a common header and footer. The header contains a main menu bar to allow navigation
among different pages.
You should also see a toolbar sticking at the bottom of the browser window when it displays any of the above pages.
This is a useful [debugger tool](tool-debugger.md) provided by Yii to help you check various debugging information
about the application execution, such as log messages, response status, database queries, and so on.
You should also see a toolbar at the bottom of the browser window.
This is a useful [debugger tool](tool-debugger.md) provided by Yii to record and display a lot of debugging information, such as log messages, response statuses, the database queries run, and so on.
Application Structure <a name="application-structure"></a>
---------------------
The following is a list of the most important directories and files in your application,
The most important directories and files in your application are (assuming the application's root directory is `basic`):
```
basic/ application base path
......@@ -44,19 +42,19 @@ basic/ application base path
commands/ contains console command classes
controllers/ contains controller classes
models/ contains model classes
runtime/ contains files generated by Yii during runtime, such as logs, cache files
vendor/ contains the installed Composer packages, including the Yii framework
runtime/ contains files generated by Yii during runtime, such as logs and cache files
vendor/ contains the installed Composer packages, including the Yii framework itself
views/ contains view files
web/ application Web root, contains Web accessible files
assets/ contains published asset files (js, css) by Yii
index.php the entry script of the application
index.php the entry (or bootstrap) script for the application
yii the Yii console command execution script
```
In general, the files in the application can be divided into two parts: those under `basic/web` and those
under other directories. The former can be directly accessed from Web, while the latter can not and should not.
In general, the files in the application can be divided into two types: those under `basic/web` and those
under other directories. The former can be directly accessed from via HTTP (i.e., in a browser), while the latter can not and should not be.
Yii implements the [model-view-controller (MVC)](http://wikipedia.org/wiki/Model-view-controller) design pattern
Yii implements the [model-view-controller (MVC)](http://wikipedia.org/wiki/Model-view-controller) design pattern,
which is reflected in the above directory organization. The `models` directory contains all [model classes](structure-models.md),
the `views` directory contains all [view scripts](structure-views.md), and the `controllers` directory contains
all [controller classes](structure-controllers.md).
......@@ -67,8 +65,8 @@ The following diagram shows the static structure of an application.
Each application has an entry script `web/index.php` which is the only Web accessible PHP script in the application.
The entry script takes an incoming request and creates an [application](structure-applications.md) instance to handle it.
The [application](structure-applications.md) resolves the request with the help of its [components](concept-components.md)
and dispatches the request to MVC. [Widgets](structure-widgets.md) are used in the [views](structure-views.md)
The [application](structure-applications.md) resolves the request with the help of its [components](concept-components.md),
and dispatches the request to the MVC elements. [Widgets](structure-widgets.md) are used in the [views](structure-views.md)
to help build complex and dynamic user interface elements.
......@@ -87,9 +85,9 @@ The following diagram shows how an application handles a request.
4. The application creates a [controller](structure-controllers.md) instance to handle the request.
5. The controller creates an [action](structure-controllers.md) instance and performs the filters for the action.
6. If any filter fails, the action is cancelled.
7. If all filters pass, the action is being executed.
7. If all filters pass, the action is executed.
8. The action loads a data model, possibly from a database.
9. The action renders a view with the data model.
10. The rendering result is to the [response](runtime-responses.md) application component.
11. The response component sends the rendering result to the user.
9. The action renders a view, providing it with the data model.
10. The rendered result is returned to the [response](runtime-responses.md) application component.
11. The response component sends the rendered result to the user's browser.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment