The content of this article is about the differences between yii2 and yii in the third PHP interview question. It has a certain reference value. Now I share it with you. Friends in need can refer to it
1 .Comsoper has been used to manage various dependencies in Yii 2.0. You can use composer to install during installation.
2. In Yii 2.0, a security event has been added to control the security of the application. You can use it easily like the following example:
Yii::$app->security->encrypt()
3. Transaction management
For transaction management, the biggest change is that you can use callback functions in things:
$connection->transaction(function() { $order = new Order($customer); $order->save(); $order->addItems($items); });
In addition , Yii 2.0 also defines some new events for transaction management so that you can better control the entire process of the transaction during the life cycle of the transaction. Events like beginTransaction and commitTransaction are such events, respectively when starting a transaction and submitting a transaction. trigger.
4.Yii2 introduces the concept of resource package, and the way of resource reference changes greatly.
There are two ways to introduce resources, one is through the AppAsset class in the assets directory, and the other is through a registration method similar to Yii1.
5. A significant change in the view layer of Yii2 is the introduction of view classes, which makes the implementation of the MVC pattern more complete. Similar to different configurations such as themes
Correspondingly, the relevant presentation layer auxiliary classes are managed by new view classes, such as theme:
1. Comsoper has been used in Yii 2.0 to manage various dependencies Relationship, you can use composer to install during installation
2. Yii 2.0 also adds a security event to control the security of the application. You can use it easily like the following example:
Yii::$app->security->encrypt()
3. Transaction management
For transaction management, the biggest change is that you can use callback functions in transactions:
$connection->transaction(function() { $order = new Order($customer); $order->save(); $order->addItems($items); });
In addition, Yii 2.0 also defines some new events for transaction management This allows you to better control the entire process of a thing during its life cycle. Events such as beginTransaction and commitTransaction are triggered when things are started and things are submitted respectively.
4.Yii2 introduces the concept of resource package, and the way of resource reference changes greatly.
There are two ways to introduce resources, one is through the AppAsset class in the assets directory, and the other is through a registration method similar to Yii1.
5. A significant change in the view layer of Yii2 is the introduction of view classes, which makes the implementation of the MVC pattern more complete. Different configurations such as similar themes
Correspondingly, the relevant presentation layer affiliated classes are taken over and managed by the new view class, such as theme:
Related recommendations:
php interview Question 2: Transmission protocols used
The above is the detailed content of PHP interview question 3: The difference between yii2 and yii. For more information, please follow other related articles on the PHP Chinese website!