Home  >  Article  >  PHP Framework  >  What features does yii2 have?

What features does yii2 have?

藏色散人
藏色散人Original
2020-07-20 10:23:002972browse

The features of yii2 are: 1. Comsoper is used in Yii2 to manage various dependencies; 2. Application security can be controlled; 3. Callback functions can be used in things; 4. Some new things are defined for things management. events; 5. There are two ways to introduce resources; 6. The view class is introduced.

What features does yii2 have?

New features of yii2 compared to yii

5 differences between yii2 and yii: composer , security events, transaction management, resource packages, view classes

Recommended: "yii Tutorial"

1. Composer: Comsoper has been used in Yii2 to manage various dependencies Relationship, you can use composer to install during installation

2. Security events: used to control the security of the application, use: Yii::$app->security->encrypt()

3. Transaction management:

(3.1) The biggest change is that you can use callback functions in things:

$connection->transaction(function() {
    $order = new Order($customer);
    $order->save();
    $order->addItems($items);
});

(3.2) Yii 2.0 also provides transaction management Define some new events so that you can better control the entire process of the thing during its life cycle. Events such as beginTransaction and commitTransaction are triggered when things are started and things are submitted respectively.

4. Resource package: 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. View class: The view class is introduced, which makes the implementation of the MVC pattern more complete. Different configurations such as similar themes. Correspondingly, the relevant presentation layer auxiliary classes are managed by the new view class, such as theme

The above is the detailed content of What features does yii2 have?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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