Last Updated: May 10, 2020
Author: Full Stack Tutoorials
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.
Component: A component is an independent piece of code written for specific task that can be used by calling in controllers (example : email component).
Helper: Yii provides many classes that help simplify common coding tasks, such as string or array manipulations, HTML code generation, and so on. These helper classes are organized under the yii\helpers namespace and are all static classes (meaning they contain only static properties and methods and should not be instantiated).You use a helper class by directly calling one of its static methods, like the following:
use yii\helpers\Html; echo Html::encode('Test > test');
1. Core Helper ClassesThe following core helper classes are provided in the Yii releases:
2. Customizing Helper ClassesTo customize a core helper class (e.g. yii\helpers\ArrayHelper), you should create a new class extending from the helpers corresponding base class (e.g. yii\helpers\BaseArrayHelper) and name your class the same as the corresponding concrete class (e.g. yii\helpers\ArrayHelper), including its namespace. This class will then be set up to replace the original implementation of the framework.
these only adds to modularity in code otherwise same coding can be implemented in controllers.
//Controller Name echo Yii::$app->controller->id;
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 and finally outputs the result. i.e) render with theme.
renderPartial() is commonly used to render a “piece” of a page. The main difference from render() is that this method does not place the results of the render in a layout. By default it also does not perform output processing, but you can override this behavior using the $processOutputparameter. i.e) render without theme.
renderFile() is a low-level method that does the grunt work of rendering: it extracts the data variables in the current scope and then runs the view code. The other two methods internally call this one, but you should practically never need to call it yourself. If you do, keep in mind that you need to pass in a file path (not a view path).
Active Record, it provides an object-oriented interface for accessing and manipulating data stored in databases.
Gii is a web-based code-generator module provided by Yii framework
It helps you create and generate fully customized forms, models, CRUD for database and more