📜 ⬆️ ⬇️

Yii 2.0.1



We are very pleased to announce the release of version 2.0.1 of the PHP framework Yii. Learn more about how to install this version or upgrade to it at http://www.yiiframework.com/download/ .

Version 2.0.1 is a patch release for branch 2.0, containing about 90 minor improvements and bug fixes. The full list of changes can be read on GitHub . In addition to the improvements to the code itself, considerable documentation work was done. Especially for the complete guide to Yii 2.0 , translated into many languages. Thanks to everyone who gave us some of their precious time improving Yii.
')
You can follow the development of the framework by placing an asterisk or clicking watch on the project page on GitHub . You can also subscribe to Twitter and join a group on Facebook .

Next will be considered the most important changes.



Forced Resource Conversion



Through asset bundle you can convert resources automatically. For example, LESS in CSS. However, tracking all changes in the source files is quite expensive. Especially when importing one resource into another is done. In such cases, you can convert resources forcibly. To do this, the assetManager component assetManager configured as follows:

 [ 'components' => [ 'assetManager' => [ 'converter' => [ 'forceConvert' => true, ] ] ] ]; 


Selection of subqueries



The query builder supports subqueries in many places. Now in SELECT :

 $subQuery = (new Query)->select('COUNT(*)')->from('user'); $query = (new Query)->select(['id', 'count' => $subQuery])->from('post'); // $query represents the following SQL: // SELECT `id`, (SELECT COUNT(*) FROM `user`) AS `count` FROM `post` 


Preventing CSS reloading with AJAX requests



In Yii, there were already tools to prevent re-loading JavaScript with AJAX requests. Now there is also for CSS. To use this feature, YiiAsset registration is YiiAsset as shown below:

 yii\web\YiiAsset::register($view); 


Clearing the database schema cache



We have added a new command to clear the database schema cache. It will be useful for putting the code on the working servers. The command runs as follows:

 yii cache/flush-schema 


Helper Improvements



The Html::cssFile() method now supports the noscript option, intended to wrap the generated link tag into a noscript tag. This option can also be used when setting AssetBundle::cssOptions . For example:

 use yii\helpers\Html; echo Html::cssFile('/css/jquery.fileupload-noscript.css', ['noscript' => true]); 


Previously, StringHelper::truncate() supported trimming a simple string to a specified number of characters or words. HTML is now supported, which remains completely valid when trimming.

The class Inflector acquired a new method, sentence() , which gathers an array of words into a sentence. For example:

 use yii\helpers\Inflector; $words = ['Spain', 'France']; echo Inflector::sentence($words); // output: Spain and France $words = ['Spain', 'France', 'Italy']; echo Inflector::sentence($words); // output: Spain, France and Italy $words = ['Spain', 'France', 'Italy']; echo Inflector::sentence($words, ' & '); // output: Spain, France & Italy 


Bootstrap enhancements



CSS framework Bootstrap updated to version 3.3.x. If you want to use the old version, you can specify it explicitly in the project composer.json .

New properties have been added to the Bootstrap widgets, described in detail in the API documentation .



MongoDB support improvements



The findAndModify operation findAndModify now supported by both yii\mongodb\Query and yii\mongodb\ActiveQuery . For example:

 User::find()->where(['status' => 'new'])->modify(['status' => 'processing']); 


MongoDB requests are now displayed on the debug pane. To use it, follow the debugger settings as follows:

 [ 'class' => 'yii\debug\Module', 'panels' => [ 'mongodb' => [ 'class' => 'yii\mongodb\debug\MongoDbPanel', ] ], ] 


Redis enhancements



The Redis extension now supports working through UNIX sockets, which is often 50% faster than working via TCP. The connection is configured as follows:

 [ 'class' => 'yii\redis\Connection', 'unixSocket' => '/var/run/redis/redis.sock', ] 

Source: https://habr.com/ru/post/245227/


All Articles