300+ Yii 2 FAQs and Answers for Experienced / Freshers

Yii 2 Interview Questions with Answers

Question: 1. What Is Yii 2 ? If it’s not too much trouble Explain? 


Yii 2 is one of the most well known Web programming structure written in PHP language.It can be utilized for building up a wide range of Web applications from sites to internet business sites and ERP’s. Yii executes the MVC (Model-View-Controller) structural example. 

Question: 2. Which Php Version Is Required To Install Yii 2.0? 


Yii 2.0 requires PHP 5.4.0 or above and runs best with the most recent adaptation of PHP 7 as well. 

PHP Interview Questions 

Question: 3. What Is Latest Version Yii 2 Framework? 


The most recent variant of Yii 2 is 2.0.12, discharged on June 5, 2017. 

Question: 4. Give Steps To Install Yii 2 Framework? 


You can introduce Yii2 by running beneath orders by means of writer: 

Author worldwide require “fxp/writer resource plugin:^1.3.1” 

Author make venture – incline toward dist yiisoft/yii2-application essential fundamental 

PHP Tutorial 

Question: 5. Show Some Features Yii2 Framework? 


Highlights of Yii Framework: 

Model-View-Controller (MVC) plan design 

Structure information and approval 

Cleaning and theming component 

Layered reserving plan 

Unit and usefulness testing 

Programmed code age 

Blunder taking care of and logging 

Database Access Objects (DAO), Query Builder, Active Record, DB Migration 

AJAX-empowered gadgets 

Internationalization and limitation 

Verification and approval 

Expansion library 

Nitty gritty documentation 

CakePHP Interview Questions 

Question: 6. Show Some Database Related Functions In Yii 2 Framework? 


The following are rundown of some database related capacities utilized in Yii 2 Framework 

discover(): Creates a yii dbActive QueryInterface occasion for inquiry reason. 


/Getting first record coordinating with condition 

$user = User::find()- >where([‘name’ => ‘Abc’])- >one(); 

Discover All(): Returns a rundown of dynamic record models that coordinate the predefined essential key value(s) or a lot of section esteems. 


/discover the clients whose essential key worth is 10 

$customers = Customer::find All (10); 

/discover clients whose age is 30 and whose status is dynamic 

$customers = Customer::find All ([‘age’ => 30, ‘status’ => ‘active’]); 

Supplement (): Inserts a line into the related database table utilizing the characteristic estimations of this record. 


$customer = new Customer; 

$customer->name = $name; 

$customer->email = $email; 


Erase(): Deletes the table column comparing to this dynamic record. 


$models = Customer::find()- >where(‘status = 3’)- >all(); 

foreach ($models as $model) { 


Erase All(): Deletes pushes in the table utilizing the gave conditions. 


Customer::delete All (‘status = 3’); 

spare() :Saves the present record. Uses: 

$customer = new Customer;/or $customer = Customer::find One ($id); 

$customer->name = $name; 

$customer->email = $email; 


Question: 7. If you don’t mind List Basic Server Requirements To Install Yii 2 Framework? 


Yii 2 requires PHP 5.4 or above with Mbstring expansion and PCRE-support. 

CakePHP Tutorial CodeIgniter Interview Questions 

Question: 8. What Is “gii” In Yii 2 And For What It Is Used? 


Gii is module amazing module gave by Yii system. It encourages you make and produce completely tweaked structures, models, CRUD for database and that’s just the beginning. You can empower Gii by designing it in the modules property of the application. Contingent on how you made your application, 

you may locate the accompanying code is as of now gave in the config/web.php setup document: 

$config = [ … ]; 

on the off chance that (YII ENV DEV) { 

$config[‘bootstrap’][] = ‘gii’; 

$config[‘modules’][‘gii’] = [ 

‘class’ => ‘yii Module’, 


Question: 9. What Is Name Of First File The Loaded When Yii Framework Starts? 


Index.php is first document that is called Yii system begins. Thus it will make another object of new YiiwebApplication and start the application. 

require(__DIR__ . ‘/../merchant/autoload.php’); 

require(__DIR__ . ‘/../merchant/yiisoft/yii2/Yii.php’); 

/load application setup 

$config = require(__DIR__ . ‘/../config/web.php’); 

/start up and design the application 

(new yiiwebApplication($config))- >run(); 

Yii Interview Questions 

Question: 10. Clarify Naming Convention In Yii 2 Framework? 


Yii follows beneath naming shows: 

You can characterize table prefix when utilizing Gii. For your situation, you have to set it to tbl_. At that point it ought to produce User Controller rather than TblUserController. 

The Yii Framework utilizes a class naming show whereby the names of the classes legitimately guide to the indexes in which they are put away. The root level index of the Yii Framework is the “structure/” catalog, under which all classes are put away progressively. 

Class names may just contain alphanumeric characters. Numbers are allowed in class names however are disheartened. Spot (.) is just allowed instead of the way separator. 

CodeIgniter Tutorial 

Question: 11. Clarify Request Life Cycle In Yii 2 Framework? 


When dealing with a client demand, Yii 2.0 application will experience the accompanying stages: 

1. Pre-instate the application with Application::preinit (); 

2. Set up the mistake taking care of; 

3. Register center application segments; 

4. Burden application design; 

5. Instate the application with Application::init() 

Register application practices; 

Burden static application segments; 

6 Raise an onBeginRequest occasion; 

7. Procedure the client demand. 

Gather data about the solicitation; 

Make a controller; 

Run the controller; 

8. Raise an onEndRequest occasion; 

Question: 12. What Are Yii Helpers? 


Assistants are static classes in Yii that improve normal coding errands, for example, string or exhibit controls, HTML code age, etc. In Yii all aides are held under yii partners namespace. 

You utilize an assistant class in Yii by straightforwardly calling one of its static strategies, similar to the accompanying: 

use yii partners Html; 

reverberation Html::encode(‘Test > test’); 

PHP Interview Questions 

Question: 13. What Are Formatted In Yii2? 


Formatter is Yii application part that is utilized organization see information in discernible configuration for clients. As a matter of course the formatter is actualized by Yiii18nFormatter which gives a lot of strategies to organize information as date/time, numbers, monetary standards, and other generally utilized arrangements. You can utilize the formatter like the accompanying, 

$formatter = Yii::$app->formatter; 

/yield: January 1, 2014 

reverberation $formatter->asDate(‘2014-01-01’, ‘long’); 

/yield: 12.50% 

reverberation $formatter->asPercent(0.125, 2); 

/yield: cebe@example.com 

reverberation $formatter->asEmail(‘cebe@example.com’); 

/yield: Yes 

reverberation $formatter->asBoolean(true); 

/it likewise handles show of invalid qualities: 

/yield: (not set) 

reverberation $formatter->asDate(null); 

Yii Tutorial 

Question: 14. What Are Components In Yii 2? 


Segments are a free arrangement of code written to perform explicit errand in controllers.Yii applications are based upon parts which are objects kept in touch with a determination. A part is a case of Component or its determined class. Utilizing a part mostly includes getting to its properties and raising/dealing with its occasions. The base class Component indicates how to characterize properties and occasions. 

Question: 15. Advantages Of Yii Over Other Frameworks? 


Like most PHP systems, Yii actualizes the MVC (Model-View-Controller) compositional example and advances code association dependent on that design. 

Yii takes the way of thinking that code ought to be written in a basic yet rich manner. Yii will never attempt to over-structure things for the most part with the end goal of carefully following some plan design. 

Yii is a full-stack system giving many demonstrated and prepared to-utilize highlights: question manufacturers and ActiveRecord for both social and NoSQL databases; RESTful API advancement support; multi-level reserving backing; and that’s only the tip of the iceberg. 

Yii is amazingly extensible. You can alter or supplant almost every bit of the center’s code. You can likewise exploit Yii’s strong augmentation design to utilize or create redistributable expansions. 

Superior is constantly an essential objective of Yii. 

Bigger Community. 

Question: 16. What Is C Model Class In Yii2? 


Yii C Model is the base class that gives the normal highlights required by information model articles. C Model characterizes the fundamental system for information models that should be approved. All Models in Yii broadens C Model class. 

Question: 17. What Is Active Record (ar) In Yii? 


Dynamic Record gives an article arranged interface to getting to and controlling information put away in databases. An Active Record class is related with a database table, an Active Record occurrence compares to a line of that table, and a characteristic of an Active Record case speaks to the estimation of a specific segment in that push. Rather than composing crude SQL articulations, you would get to Active Record characteristics and call Active Record strategies to get to and control the information put away in database tables. 

Question: 18. What Is Difference Between “render” And “render Partial” In Yii? 


Render work is utilized to render a view in Yii with determined design though render fractional is utilized to render just view format is excluded from see. 

RenderPartial is essentially utilized when we need to refresh a bit of page by means of AJAX. 


Render (‘yourviewname’); 

RenderPartial (‘yourviewpartial’); 

CakePHP Interview Questions 

Question: 19. How To Get Current Url In Yii? 


Yii::app () – >request->getUrl () strategy is utilized to get present url in Yii structure.

Leave a Reply

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