New issue of Yii development notes: 2.0 releases, 2.1 post by Paul, https for Yii-realted websites and, finally, official site launch.
Mar 23, 2018
New issue of Yii development notes: 2.0 releases, 2.1 post by Paul, https for Yii-realted websites and, finally, official site launch.
Mar 22, 2018
Yii team is ready to release new yiiframework.com website. The announcement itself is interesting but since it may not be available for some time, here's most important part:
We are going to switch to the new website on March 23, 2018 in the time frame 8:00 to 12:00 UTC. During the switch, you will not be able to write comments, wikis, forum entries etc. Also the documentation may not be available. You can use http://stuff.cebe.cc/yii2docs/ to view the documentation.
We will be avilable in the Slack chat and on IRC #yii on freenode, so if you need help, get there.
Mar 20, 2018
Yii team released security fixes for framework and extensions. Details are in the announcements. Please update.
Mar 14, 2018
Carsten Brandt (@cebe) released new version of his markdown library that is used to render markdown in Yii including definitive guide and API docs.
Mar 14, 2018
A hotfix release was tagged yesterday. There are mostly 2.0.14 regressions and other bug fixes. No new features or intentional backwards compatibility breaks so it's safe to update.
Mar 3, 2018
Interested developers are welcome to try Yii 2.1 branch, which is already available for early access. It brings many new features and embraces PSR standards. However, it also brings significant backwards compatibility break. While it is not yet finished, it is already prepared for usage as a development platform.
Warning: Yii 2.1 branch is unstable and can be broken anytime, its current code may change dramatically before actual release. Do NOT attempt ot use it for the actual projects in 'production' stage, unless you are ready to deal with the consequences!
You can browse Yii 2.1 code at GitHub and install it using "2.1.x-dev" version for "yiisoft/yii2" Composer package.
In order to install Yii 2.1, you should specify version "2.1.x-dev" for "yiisoft/yii2" package in your 'composer.json' file:
"require": {
"yiisoft/yii2": "2.1.x-dev",
...
}
Attention: since 2.1 Yii dropped its own PHP class autoloader in favor of the one provided by Composer. Thus you will need to configure "autoload" for your project at 'composer.json' otherwise PHP script will be unable to find classes declared at your project.
For example:
{
"autoload": {
"psr-4": {"app\\": ""}
},
"autoload-dev": {
"psr-4": {"tests\\": "tests"}
},
...
}
In case autoload for the project files is missing web application will trigger Yii application error like "Unable to resolve request 'site/error'".
Note that in 2.1 some former "yiisoft/yii2" package classes have been moved into separate repositories:
In case your project requires one of these, you should add corresponding packages to
your composer.json
. So in order get full equivalent of Yii 2.0 for 2.1, composer configuration should be the following:
"require": {
"yiisoft/yii2": "2.1.x-dev",
"yiisoft/yii2-jquery": "1.0.x-dev",
"yiisoft/yii2-captcha": "1.0.x-dev",
"yiisoft/yii2-rest": "1.0.x-dev",
"yiisoft/yii2-mssql": "1.0.x-dev",
"yiisoft/yii2-oracle": "1.0.x-dev",
"yiisoft/yii2-maskedinput": "1.0.x-dev",
...
}
Most of the official extensions also have development branches compatible with Yii 2.1. The following composer configuration example will install all extensions available for 2.1:
"require": {
"yiisoft/yii2": "2.1.x-dev",
...
"yiisoft/yii2-debug": "2.1.x-dev",
"yiisoft/yii2-gii": "2.1.x-dev",
"yiisoft/yii2-swiftmailer": "2.2.x-dev",
"yiisoft/yii2-bootstrap": "2.2.x-dev",
"yiisoft/yii2-jui": "2.1.x-dev",
"yiisoft/yii2-httpclient": "2.1.x-dev",
"yiisoft/yii2-authclient": "2.2.x-dev",
"yiisoft/yii2-mongodb": "2.2.x-dev",
"yiisoft/yii2-sphinx": "2.2.x-dev",
"yiisoft/yii2-imagine": "2.2.x-dev",
"yiisoft/yii2-faker": "2.1.x-dev"
}
Ensure that you code does not use any deprecated constructions like following:
className()
, e.g. SomeClass::className()
. It should be replaced by native PHP ::class
constructionyii\base\InvalidParamException
. It should be replaced by yii\base\InvalidArgumentException
yii\console\Controller
constants, e.g. EXIT_CODE_NORMAL
or EXIT_CODE_ERROR
, for exit code.
They should be replaced by constants provided via yii\console\ExitCode
class.Any DI object configuration should use '__class' keyword instead of 'class' for the class name specification.
This affects DI container, Yii::createObject()
and thus any application component specification.
So former Yii application config like following:
return [
'components' = [
'mailer' => [
'class' => yii\swiftmailer\Mailer::class,
],
'mutex' => [
'class' => yii\mutex\FileMutex::class
],
'db' => [
'class' => yii\db\Connection::class,
'dsn' => 'mysql:host=localhost;dbname=myproject',
'username' => '???',
'password' => '???',
],
]
];
now should look like this:
return [
'components' = [
'mailer' => [
'__class' => yii\swiftmailer\Mailer::class,
],
'mutex' => [
'__class' => yii\mutex\FileMutex::class
],
'db' => [
'__class' => yii\db\Connection::class,
'dsn' => 'mysql:host=localhost;dbname=myproject',
'username' => '???',
'password' => '???',
],
// ...
],
// ...
];
At 2.1 logging has been rewritten according to PSR-3, which in particular allows you to use Monolog
as logger for your project.
Application component 'log' does not exist anymore. You should configure logger directly via Yii::setLogger()
or using Application::setLogger()
, e.g. 'logger' key in application config.
So former Yii log config like following:
return [
'bootstrap' => [
'log', // should be removed for 2.1
],
'components' = [
// should be converted to 'logger' for 2.1
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => yii\log\FileTarget::class,
'levels' => ['error', 'warning'],
],
],
],
// ...
],
// ...
];
now should look like this:
return [
// no bootstrap
'logger' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'__class' => yii\log\FileTarget::class,
'levels' => ['error', 'warning'],
],
],
],
'components' = [
// no 'log' component
// ...
],
// ...
];
At 2.1 caching has been rewritten according to PSR-16, which allows your usage of 3rd party cache providers easily.
In order to keep 'cache dependency' feature cache specification has been changed.
Now any cache component should use yii\caching\Cache
class (or implement yii\caching\CacheInterface
), while
actual cache storage is determined via Cache::$handler
.
So former Yii cache config like following:
return [
'components' = [
'cache' => [
'class' => yii\caching\DbCache::class,
'cacheTable' => 'my_cache',
],
// ...
],
// ...
];
now should look like this:
return [
'components' = [
'cache' => [
'__class' => yii\caching\Cache::class,
'handler' => [
'__class' => yii\caching\DbCache::class,
'cacheTable' => 'my_cache',
],
],
// ...
],
// ...
];
Be careful: it may happen, that in case of incorrect cache configuration (e.g. using old one), you will not receive an immediate error, but just some latent incorrect behavior.
As it was already said all JQuery related code has been moved to "yiisoft/yii2-jquery" package.
This, in particular, includes yii.js
, client-side validation for ActiveForm
and filter handler for GridView
.
Without extra adjustments simple usage of ActiveForm
or GridView
widget will no longer provide any
JavaScript code registration, and thus no 'fancy' client-side effects.
You will need to attach 'clientScript' behavior to the widget in order to make it behave like before.
ActiveForm example:
<?php $form = ActiveForm::begin([
'id' => 'login-form',
'as clientScript' => yii\jquery\ActiveFormClientScript::class, // attach JQuery client script, enabling client-side validation:
]); ?>
...
<?php ActiveForm::end(); ?>
GridView example:
<?= GridView::widget([
'as clientScript' => yii\jquery\GridViewClientScript::class, // attach JQuery client script, enabling filter auto-submit
'dataProvider' => $dataProvider,
// ...
]); ?>
In order to get more clear impression on Yii 2.1 usage, you may refer to the working project template, which has been already updated to 2.1 - ii2tech/project-template
Install via composer:
composer create-project --prefer-dist --stability=dev yii2tech/project-template yii-test 2.0.x-dev
Install via git:
# clone repo:
git clone git@github.com:yii2tech/project-template.git yii-test
# go to project:
cd yii-test
# get 2.0 branch:
git fetch
git checkout 2.0
In order to configure project and make it running run 'install.php' file:
cd yii-test
php install.php
Feb 19, 2018
Fresh pack of manuals in various formats: CHM, PDF, webhelp, MS Word.
Changelog:
Feb 19, 2018
Yii team tagged Faker extension version 2.0.4. It containes small bug fixed and enhancements.
Feb 19, 2018
Another issue of Yii development notes was posted summing up what happened in 2018 so far and giving some interesting links to check.
Feb 19, 2018
Yii team released 2.0.14 version of the framework. It's the last version of 2.0 with enhancements on board and there are many. From now on team will focus on 2.1.