Home > Backend Development > PHP Tutorial > PHP interview question 3: The difference between yii2 and yii

PHP interview question 3: The difference between yii2 and yii

不言
Release: 2023-03-24 09:18:02
Original
4697 people have browsed it

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()
Copy after login
Copy after login

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);
});
Copy after login

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()
Copy after login
Copy after login

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);
});
Copy after login

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

php interview question 1: The difference between threads and processes (by the way, coroutines are mentioned)

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template