Yii Fundamentals Flashcards
(115 cards)
How can you run Yii in debug mode?
Define the YII_DEBUG constant as true, before including the yii.php file.
The application object is also called the…
…front controller.
Name three things that the application object does.
- Collects information about the request.
- Dispatches request information to the appropriate controller for further processing.
- Stores application-level configuration settings.
The application object is instantiated as a _ by the _ _.
Singleton, entry script.
How can you access the application singleton?
Yii:app().
Where is the main application configuration stored?
In protected/config/main.php.
By default, the application object is an instance of…
…CWebApplication.
How do you apply application configuration?
By passing the configuration filename as a parameter to the application’s constructor, like this: $app=Yii::createWebApplication($configFile)
How do you protect the contents of the /protected directory from view?
With a .htaccess file containing “deny from all”.
How do you customize the class and property values of any application component used?
By configuring the ‘components’ property of the application instance.
How can you access an application component?
Use Yii:app()->ComponentID, where ComponentID refers to the ID of the component.
How do you disable an application component?
Set ‘enabled’ to ‘false’ in its configuration.
By default, are application components created on demand?
Yes.
How can you create an application component regardless of whether it is accessed or not?
List its ID in the ‘preload’ application property.
List all 15 core components that are pre-declared by CWebApplication.
AssetManager AuthManager Cache ClientScript DbConnection ErrorHandler Formatter HttpRequest HttpSession PhpMessageSource SecurityManager StatePersister ThemeManager UrlManager WebUser
List the 8 steps in an application life cycle.
- Pre-initialize the application with CApplication:preinit().
- Setup the class autoloader and error handling.
- Register core application components.
- Load application configuration.
- Initialize the application with CApplication:init().
- Raise an onBeginRequest event.
- Process the user request: collect request information, create a controller, run a controller.
- Raise an onEndRequest event.
A controller is an instance of…
…CController, or a class that extends CController.
What is an action?
A controller class method whose name begins with “action”.
How is a route formed?
By concatenating a controller ID and an action ID, separated by a slash.
By default, are routes case-sensitive?
Yes.
What is the route for a controller action inside a module?
moduleID/controllerID/actionID.
When is a controller instance created?
When CWebApplication handles an incoming request.
For a controller ID of admin/user, what class file is it mapped to?
protected/controllers/admin/UserController.php.
What’s action parameter binding?
It’s when a controller action method can define named parameters whose value will be automatically populated from $_GET.