Quantcast
Channel: Live News for Yii Framework
Viewing all articles
Browse latest Browse all 2941

[News] Yii 2.0.1 is released

$
0
0

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.

You may follow the development progress of Yii 2 by starring or watching Yii 2.0 GitHub Project. You may also follow Yii Twitter feeds or join Yii Facebook group to connect with other Yii developers.

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' => [
                'forceConversion' => true,
            ]
        ]
    ]
];

Selecting Sub-queries

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

Previously, Yii has support for preventing loading the same JavaScript files in AJAX responses. It now also supports preventing loading the same CSS files in AJAX responses. To use this feature, all you need to is simply to use the YiiAsset asset bundle like the following:

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

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:

yii cache/flush-schema

Enhancements to Helpers

The 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]);

Previously 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.

The 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 composer.json file.

New properties are added for several Bootstrap widgets. Please refer to the Class Reference for more detailed information.

  • yii\bootstrap\ButtonDropdown::$containerOptions
  • yii\bootstrap\Modal::$headerOptions
  • yii\bootstrap\Modal::$footerOptions
  • yii\bootstrap\Tabs::renderTabContent
  • yii\bootstrap\ButtonDropdown::$containerOptions

Enhancements to MongoDB Extension

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

User::find()->where(['status' => 'new'])->modify(['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',
]

Viewing all articles
Browse latest Browse all 2941

Trending Articles