Controller --- CController
- An instance of CController or of a class that extends CController.
- It is created by the application object when the user requests it.
action is just a controller class method whose name starts with
- actionIndex() is the defaultaction, when the user request doesn’t specify any action it will be executed
- The defaultaction can be changed by setting the public instance variable, Ccontroller::defaultAction.
- Controllers and actions are identified by IDs.
- For e.g. the route “http://localhost/testApp/index.php?r=site/login” will call actionLogin of siteController
- By default, the route are case-sensitive. By setting CUrlManager::caseSensitive to false in the application configuration, we can make the routes case-insensitive .
When handling a user request, an application will undergo the following life cycle:
1. Pre-initialize the application with Capplication::preinit();
2. Load application configuration
3. Set up class autoloader and error handling
4. Register core application components;
5. Initialize the application with CApplication::init()
Bootstrap PHP script or Entry script
- It handles user requests initially.
- It is the only PHP script that end users can directly request to execute.
- It contains the following code:
1. // remove the following line when in production mode
2. defined(‘YII_DEBUG’) or define(‘YII_DEBUG’,true);
3. // include Yii bootstrap file
5. // create application instance and run
Yii – An MVC Framework
model => information (the data) and the business rules
view => elements of the user interface such as text, form inputs;
controller => manages the communication between the model and the view.
A front-controller named application => access all the incoming request and dispatches it to the appropriate controllers for further processing.