We are very pleased to announce the release of Yii Framework version 2.0.1. Please refer to the instructions at http://www.yiiframework.com/download/ to install or upgrade to this version.
Version 2.0.1 is a patch release of Yii 2.0 which contains about 90 minor new features and bug fixes. Complete list of changes may be found in the change log. Besides code improvement, there are also a lot of improvements about the documentation, especially the Definitive Guide to Yii 2.0 which have been translated into several languages. We hereby thank to all contributors who have spent their precious time helping improve Yii and made this release possible.
Below we summarize some of most important features included in this release.
Forcing Asset Conversion
Asset bundle supports automatic asset conversion, such as converting LESS into CSS. However, it is costly to ensure proper detection of source asset changes, especially when one asset is imported by another. To solve this problem, you may now configure
assetManager like the following to force converting assets always:
[ 'components' => [ 'assetManager' => [ 'converter' => [ 'forceConvert' => true, ] ] ] ];
Query builder supports using sub-queries in different places. Now you can also use sub-queries in the
SELECT part. For example,
$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 in AJAX
YiiAsset asset bundle like the following:
Flushing Schema Cache
A new console command is added to allow you to flush schema cache. This is useful when you deploy code that cause DB schema changes to production servers. Simply run the command as follows:
Enhancements to Helpers
Html::cssFile() method now supports the
noscript option, which will enclose the generated
link tag within a
noscript tag. You may also use this option when configuring the
AssetBundle::cssOptions property of an asset bundle. For example,
use yii\helpers\Html; echo Html::cssFile('/css/jquery.fileupload-noscript.css', ['noscript' => true]);
StringHelper::truncate() only supports truncates a string as a plain text string. It now supports truncating an HTML string and makes sure the truncated result remains a valid HTML string.
Inflector class gets a new method named
sentence() which concatenates a few 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
Enhancements to Bootstrap Extension
First, Twitter Bootstrap is upgraded to version 3.3.x. If you want to stick to older versions, you may explicitly specify it in your project's
New properties are added for several Bootstrap widgets. Please refer to the Class Reference for more detailed information.
Enhancements to MongoDB Extension
findAndModify operation is now supported by both
yii\mongodb\ActiveQuery. For example,
User::find()->where(['status' => 'new'])->modify(['$set'=>['status' => 'processing']]);
A debug panel is also added to display MongoDB queries performed. To use the panel, simply configure the Yii debugger as follows,
[ 'class' => 'yii\debug\Module', 'panels' => [ 'mongodb' => [ 'class' => 'yii\mongodb\debug\MongoDbPanel', ] ], ]
Enhancements to Redis Extension
The Yii Redis extension now supports using UNIX socket connection, which can be 50% faster comparing to TCP-based connection. To use it, configure the redis connection like the following:
[ 'class' => 'yii\redis\Connection', 'unixSocket' => '/var/run/redis/redis.sock', ]