Yii Interview Questions and Answers – Part 1

1. What is Yii ?
Yii is a high-performance, component-based PHP framework for developing large-scale Web applications rapidly. It enables maximum reusability in Web programming and can significantly accelerate your Web application development process.

2. What are the requirements need for use Yii framework?
you need a Web server that supports PHP 5.1.0.
You also have knowledge on object-oriented programming (OOP).

3. What is Yii best for?
Yii is a generic Web programming framework that can be used for developing virtually any type of Web application. Because it is light-weight and equipped with sophisticated caching mechanisms, it is especially suited to high-traffic applications, such as portals, forums, content management systems (CMS), e-commerce systems, etc.

4. How to install Yii framework ?
Installation of Yii mainly involves the following two steps:
a. Download Yii Framework from yiiframework.com.
b. Unpack the Yii release file to a Web-accessible directory.

5. What command used to create new Yii project ?
% YiiRoot/framework/yiic webapp WebRoot/testdrive

6. Explain structure of Yii Project?

   index.php                 Web application entry script file
   index-test.php            entry script file for the functional tests
   assets/                   containing published resource files
   css/                      containing CSS files
   images/                   containing image files
   themes/                   containing application themes
   protected/                containing protected application files
      yiic                   yiic command line script for Unix/Linux
      yiic.bat               yiic command line script for Windows
      yiic.php               yiic command line PHP script
      commands/              containing customized 'yiic' commands
         shell/              containing customized 'yiic shell' commands
      components/            containing reusable user components
         Controller.php      the base class for all controller classes
         UserIdentity.php    the 'UserIdentity' class used for authentication
      config/                containing configuration files
         console.php         the console application configuration
         main.php            the Web application configuration
         test.php            the configuration for the functional tests
      controllers/           containing controller class files
         SiteController.php  the default controller class
      data/                  containing the sample database
         schema.mysql.sql    the DB schema for the sample MySQL database
         schema.sqlite.sql   the DB schema for the sample SQLite database
         testdrive.db        the sample SQLite database file
      extensions/            containing third-party extensions
      messages/              containing translated messages
      models/                containing model class files
         LoginForm.php       the form model for 'login' action
         ContactForm.php     the form model for 'contact' action
      runtime/               containing temporarily generated files
      tests/                 containing test scripts
      views/                 containing controller view and layout files
         layouts/            containing layout view files
            main.php         the base layout shared by all pages
            column1.php      the layout for pages using a single column
            column2.php      the layout for pages using two columns
         site/               containing view files for the 'site' controller
            pages/           containing "static" pages
               about.php     the view for the "about" page
            contact.php      the view for 'contact' action
            error.php        the view for 'error' action (displaying external errors)
            index.php        the view for 'index' action
            login.php        the view for 'login' action

7. How to connect database on Yii Project?
To use a database, we need to tell the application how to connect to it. This is done in the application configuration fileWebRoot/testdrive/protected/config/main.php, highlighted as follows,

return array(

8. How to configure gii web based code generator tool on Yii Project?
In order to use Gii, we first need to edit the file WebRoot/testdrive/protected/config/main.php, which is known as the application configuration file:

return array(
            'password'=>'pick up a password here',

9. What is MVC ? Why need to use MVC?
MVC (Model – View- Controller ) is a design pattern., which is widely adopted in Web programming.
MVC aims to separate business logic from user interface considerations, so that developers can more easily change each part without affecting the other. In MVC, the model represents the information (the data) and the business rules; the view contains elements of the user interface such as text, form inputs; and the controller manages the communication between the model and the view.

10. How to change debug mode to production mode on yii project ?
Just define YII_DEBUG is false on entry script (root/index.php).

// remove the following line when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',false);
// include Yii bootstrap file
// create application instance and run
Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

Your email address will not be published. Required fields are marked *

− 1 = six

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter