Yii Interview Questions & Answers

    1. Question 1. What Is Yii Framework?Answer :

      Yii is a high-performance component-based PHP framework best for Web 2.0 development.


    1. Question 2. What Yii Is So Fast?Answer :

      Yii is so much faster because it is using the lazy loading technique extensively. For example, it does not include a class file until the class is used for the first time; and it does not create an object until the object is accessed for the first time. Other frameworks suffer from the performance hit because they would enable a functionality (e.g. DB connection, user session) no matter it is used or not during a request.


PHP Interview Questions

    1. Question 3. Can You Remember What Is Directory Structure When You Downloaded Yii?Answer :

      params-local.php *


      main-local.php *
      params-local.php *
      yiic.php *
      main-local.php *
      params-local.php *

      index.php *



    1. Question 4. What Is The First File That Gets Loaded When You Run A Application Using Yii?Answer :



PHP Tutorial

    1. Question 5. What Is Model,view,controller?Answer :

      Models represent the underlying data structure of a Web application. Models are often shared among different sub-applications of a Web application. For example, a LoginForm model may be used by both the front end and the back end of an application; a News model may be used by the console commands, Web APIs, and the front/back end of an application. Therefore, models

      • should contain properties to represent specific data;
      • should contain business logic (e.g. validation rules) to ensure the represented data fulfills the design requirement;
      • may contain code for manipulating data. For example, a SearchForm model, besides representing the search input data, may contain a search method to implement the actual search.

      Views are responsible for presenting models in the format that end users desire. In general, views

      • should mainly contain presentational code, such as HTML, and simple PHP code to traverse, format and render data;
      • should avoid containing code that performs explicit DB queries. Such code is better placed in models.
      • should avoid direct access to $_GET, $_POST, or other similar variables that represent the end user request. This is the controller’s job. The view should be focused on the display and layout of the data provided to it by the controller and/or model, but not attempting to access request variables or the database directly.
      • may access properties and methods of controllers and models directly. However, this should be done only for the purpose of presentation.

      Controllers are the glue that binds models, views and other components together into a runnable application. Controllers are responsible for dealing directly with end user requests. Therefore, controllers

      • may access $_GET, $_POST and other PHP variables that represent user requests;
      • may create model instances and manage their life cycles. For example, in a typical model update action, the controller may first create the model instance; then populate the model with the user input from$_POST; after saving the model successfully, the controller may redirect the user browser to the model detail page. Note that the actual implementation of saving a model should be located in the model instead of the controller.
      • should avoid containing embedded SQL statements, which are better kept in models.
      • should avoid containing any HTML or any other presentational markup. This is better kept in views.


Zend Interview Questions

    1. Question 6. What Is The Naming Convention Inyii?Answer :

      You can define table prefix when using Gii. In your case you need to set it to tbl_. Then it should  generate UserController instead of TblUserController.

      The Yii Framework employs a class naming convention whereby the names of the classes directly map to the directories in which they are stored. The root level directory of the Yii Framework is the “framework/” directory, under which all classes are stored hierarchically.

      Class names may only contain alphanumeric characters. Numbers are permitted in class names but are discouraged. Dot (.) is only permitted in place of the path separator.



    1. Question 7. What Is The Component,helper And Why Are They Used,is There Other Way We Can Do Same Thing,what Is Better?Answer :

      A component is an independent piece of code written for specific task that can be used by calling in controllers (example : email component), helper is used for helping yii in rendering the data to be shown to user with views, these only adds to modularity in code otherwise same coding can be implemented in controllers.


Zend Tutorial
PHP and Jquery Interview Questions

    1. Question 8. How Do You Proceed When You Have To Use Yii For Any Application?Answer :

      take the framework either from Yii site or if you have changed according to your needs start from there. Proceed with basic software engg. concepts as requirement gathering etc..

      This is a basic Understanding Concept in yii

      1. Yii-based apps are driven by data logic. When I build an app, I always start by making sure that my database schemes are well-designed and optimised to fit the business flow of the app. Therefore, my codes are automatically generated based on my database design. And, yes…
      2.  … Yii can generate the whole shebang of PHP codes for you automatically! Just define which database you want to use, and with a few clicks it will create a CRUD (create-read-update-delete) app for you. It looks so cute, I tell you! Speaking of automatic…
      3. … Yii can generate a skeleton app for you automatically. This skeleton app include a view page, a login page, contact page and basic navigation, all wrapped within a completely organized folder tree based on the standard MVC programming model.
      4. The extensive choice of Yii functions makes sense. As a self-taught web programmer, I was able to map out its functions to all of the RESPONSE and REQUEST tasks I most often use when building webapps within a matter of minutes. It also doesn’t hurt that the Yii community has kindly provided cheat sheets for the functions so that I can do a quick reference when I need to.
      5. The Definitive Guide to Yii document that comes with the Yii install is actually quite easy to go through, at least for me. I don’t know why, though. I thought CakePHP docs were more user-friendly and attractive, but surprisingly I was able to go through Yii documentation and tutorial in just two hours and not get cross-eyed by the end of it.
      6. Yii uses MySQL and SQLite as its choice database types. Of course, you can run any other type of databases as long as you have its PDO enabled in your php.ini file. I develop using MySQL most of the time, but my fondness for SQLite is increasing, due to the fact that SQLite is so darn lightweight and easy to use.
      7. Yii is integrated with jQuery, which means that many of the necessary validation functions I use can easily be plugged within the Yii function calls itself, which is usually only a line of code or two.
      8. Yii is open-source, and it’s free. Open-source products turn me on.



    1. Question 9. What Is The First Function That Gets Loaded From A Controller?Answer :



PHP+MySQL Interview Questions

    1. Question 10. What Is Habtm?Answer :
      • HasAndBelongsToMany
      • has and belongs to many is a kind of associations that can be defined in models for retrieving associated data across different entities


PHP and Jquery Tutorial

    1. Question 11. How Can We Use Ajax In Yii?Answer :

      by calling ajax helper and then using it in controller for rendering.


Sybase Interview Questions

    1. Question 12. If You Have To Validate A Registrations Module For A User, What All Can Be Possible Ways, Which One Is The Best?Answer :

      can be done on submission in controller, or using javascript/ajax while user is still filling the data. Second option is better.



PHP Interview Questions

    1. Question 13. Can You List Some Database Related Functions In Yii?Answer :

      find, findAll , findByPk , find By ,query


Magento Tutorial

    1. Question 14. How Can You Include A Javascript Menu Throught The Site? Give Steps?Answer :

      By adding the javascript files in webroot and call them in default views if needed everywhere or just in the related views.



    1. Question 15. How To Install Or Setup Yii-framework In Your Local System ?Answer :

      To install Yii you need to

      1. Download the Yii code from its official website or github.
      2. Extract the code into your server root directory.
      3. Open command line terminal and type the following command.
        php path-to-yii-folder/framework/yiic webapp [webapp-name]
      4. After execution of above command , it will ask you for the confirmation of creating your application , on selecting yes , this will create a defaut application.


Dbase Interview Questions

    1. Question 16. How To Configure Yii Aplication With Database ?Answer :

      In default application of yii, open the main.php file exists in protected/config/main.php and search for a parameter named as db, there you can add host-name, database name , username and password of your database server.



WordPress Tutorial

    1. Question 17. How You Can Create And Work With Different Module In Yii ?Answer :

      To create a module access gii url and there you can create a module. after creating a module from gii you need to add it the mai configuration file of your yii application.

      localhost/your-app/index.php?r=gii // utl to access gii

      ‘modules’ =>  array(
      ‘user’ =>  array(
      ‘activeAfterRegister’ =>  false,


Magento Interview Questions

    1. Question 18. What Is “gii” And Why It Is Used ?Answer :

      Gii is a module that provides Web-based code generation capabilities. To work with gii, you need to change the main configuration file of your application like following.

      return array(
      ‘password’=>[*choose a password*]

      To access gii in your local system, hit the url on your browser localhost/your-app/index.php?r=gii. You need to type the password that you have set in the main configuration of your app. to proceed further.



Zend Interview Questions

    1. Question 19. How You Can Remove Index.php From Your Application Url ?Answer :

      Steps to remove index.php from your application url.

      Step 1: First configure your Yii-application configuration file like below code

      ‘urlFormat’=>’path’,  //mandatory
      ‘showScriptName’=>false,   //mandatory
      ‘urlSuffix’=>’.html’,   //not mandatory

      Step 2: Enable apache rewrite engine. To enable rewrite engine type the following command in your terminal (Ubuntu ).

      a2enmod rewrite // to enable rewrite engine
      #Restart apache2 after
      /etc/init.d/apache2 restart
      service apache2 restart

      Step 3: Then, if you’d like, you can use the following .htaccess file in your application folder where index.php exists

      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]

      Thats all the 3 steps to remove index.php from the URL.


CakePHP Tutorial

  1. Question 20. What Is The Difference Between “render” And “renderpartial” ?Answer :

    render() is commonly used to render a view that corresponds to what a user sees as a “page” in your application. It first renders the view you have specified and then renders the layout for the current controller action (if applicable), placing the result of the first render into the layout. It then performs output processing (which at this time means automatically inserting any necessary