Monday 11 April 2016

YII interview questions and answers for fresher

yii interview questions and answers for fresher

Question: What is Yii?
Yii is a PHP framework which is based on MVC (Model View Controller).


Question: Is it opensource?
Yes, It is opensource. Download and use as per your project requirement. Question: What is full form of Yii
Yes it is.


Question: In which language, It is written?
PHP.


Question: What is current stable version of Yii?
Version: 2.0.7 dated February 14, 2016.


Question: What is offical website of Yii Framework?
http://www.yiiframework.com


Question: From where i an download Yii Framework?
http://www.yiiframework.com/download


Question: How to start Yii?
http://www.yiiframework.com/tour


Question: What are main feature of Yii framework?
  1. MVC design pattern
  2. Web Service available for Apps like android
  3. Internationalization and localization translation for multilingual.
  4. Caching for speed up the application
  5. Error handling and logging for tracking
  6. cross-site scripting (XSS), cross-site request forgery (CSRF) protection
  7. PHPUnit and Selenium for testing.
  8. Automatic code generation help us to fast development.



Question: How to set default controller on Yii?
array(
    'name'=>'Yii Framework',
    'defaultController'=>'site',
);



Question: How to get current controller id?
echo Yii::app()->controller->id;



Question: How to get current action id?
echo Yii::app()->action->id;



Question: What is the first function that gets loaded from a controller? ?
index



Question: How can we use ajax in Yii?
use ajax helper


Question: What are two type of models in YII
  1. Form models
  2. active records


Question: What are active records model?
Active Record is a design pattern used to abstract database access in an object-oriented way.
active records model is based on this design pattern.


Question: How to define a form model?
class MyLoginForm extends CFormModel
{
    public $username;
    public $password;
    public $rememberMe=false;
}



Question: How to set validation in Form Model?
class MyLoginForm extends CFormModel
{
    public $username;
    public $password;
    public $rememberMe=false; 
    private $_identity;
 
    public function rules()
    {
        return array(
            array('username, password', 'required'),
            array('rememberMe', 'boolean'),
            array('password', 'authenticate'),
        );
    }
 
    public function authenticate($attribute,$params)
    {
        $this->_identity=new UserIdentity($this->username,$this->password);
        if(!$this->_identity->authenticate())
            $this->addError('password','username or password Incorrect .');
    }
}



Question: What are the core application components available on Yii?
  1. db- database connection.
  2. assetManager - manage the publishing of private asset files
  3. authManager - manage role-based access control
  4. cache- manage caching functionality
  5. clientScript- manage javascript and CSS
  6. coreMessages- provides translated core messages
  7. errorHandler- manage errors handling.
  8. themeManager- Manage themes
  9. urlManager- URL parsing and creation functionality
  10. statePersister- mechanism for persisting global state
  11. session- Session management
  12. securityManager- Security Managment