@ -41,20 +41,20 @@ via simple and elegant interfaces.
Yii Versions
Yii Versions
------------
------------
Yii currently has three major versions available: 1.1, 2.0 and 2.1. Version 1.1 is the old generation and is now in maintenance mode. Version 2.0 is a complete rewrite of Yii, adopting the latest
Yii currently has three major versions available: 1.1, 2.0 and 3. Version 1.1 is the old generation and is now in maintenance mode. Version 2.0 is a complete rewrite of Yii, adopting the latest
technologies and protocols, including Composer, PSR, namespaces, traits, and so forth. Version 2.1 is a cleaned up and refactored version of 2.0 that represents the current
technologies and protocols, including Composer, PSR, namespaces, traits, and so forth. Version 3 is a cleaned up and refactored version of 2.0 that represents the current
generation of the framework and will receive the main development efforts over the next few years.
generation of the framework and will receive the main development efforts over the next few years.
This guide is mainly about version 2.1.
This guide is mainly about version 3.
Requirements and Prerequisites
Requirements and Prerequisites
------------------------------
------------------------------
Yii 2.1 requires PHP 7.1 or above. You can find more detailed
Yii 3 requires PHP 7.1 or above. You can find more detailed
requirements for individual features by running the requirement checker included in every Yii release.
requirements for individual features by running the requirement checker included in every Yii release.
Using Yii requires basic knowledge of object-oriented programming (OOP), as Yii is a pure OOP-based framework.
Using Yii requires basic knowledge of object-oriented programming (OOP), as Yii is a pure OOP-based framework.
Yii 2.1 also makes use of the latest features of PHP, such as [namespaces](http://www.php.net/manual/en/language.namespaces.php)
Yii 3 also makes use of the latest features of PHP, such as [namespaces](http://www.php.net/manual/en/language.namespaces.php)
and [traits](http://www.php.net/manual/en/language.oop5.traits.php). Understanding these concepts will help
and [traits](http://www.php.net/manual/en/language.oop5.traits.php). Understanding these concepts will help
@ -533,7 +533,7 @@ and `http://example.com/path/` are different URLs, serving the same content for
By default normalizer collapses consecutive slashes, adds or removes trailing slashes depending on whether the
By default normalizer collapses consecutive slashes, adds or removes trailing slashes depending on whether the
suffix has a trailing slash or not, and redirects to the normalized version of the URL using [permanent redirection](https://en.wikipedia.org/wiki/HTTP_301).
suffix has a trailing slash or not, and redirects to the normalized version of the URL using [permanent redirection](https://en.wikipedia.org/wiki/HTTP_301).
The normalizer can be configured globally for the URL manager or individually for each rule - by default each rule will use the normalizer
The normalizer can be configured globally for the URL manager or individually for each rule - by default each rule will use the normalizer
from URL manager. Since version 2.1.0 normalizer is enabled by default in [[yii\web\UrlManager|UrlManager]]. You can set
from URL manager. Since version 3.0.0 normalizer is enabled by default in [[yii\web\UrlManager|UrlManager]]. You can set
[[yii\web\UrlRule::$normalizer|UrlRule::$normalizer]] to `false` to disable normalization for particular URL rule.
[[yii\web\UrlRule::$normalizer|UrlRule::$normalizer]] to `false` to disable normalization for particular URL rule.
The following shows an example configuration for the UrlNormalizer:
The following shows an example configuration for the UrlNormalizer:
- Bug #16065: Remove using `date.timezone` at `yii\base\Application`, use `date_default_timezone_get()` instead (sashsvamir)
- Bug #16065: Remove using `date.timezone` at `yii\base\Application`, use `date_default_timezone_get()` instead (sashsvamir)
@ -604,7 +604,7 @@ Yii Framework 2 Change Log
- Enh #12758: Added the ability to use instances of `\yii\db\Query` class as values in the `\yii\db\QueryBuilder::insert()` method (PowerGamer1)
- Enh #12758: Added the ability to use instances of `\yii\db\Query` class as values in the `\yii\db\QueryBuilder::insert()` method (PowerGamer1)
- Enh #12771: Skip \yii\rbac\PhpManager::checkAccessRecursive and \yii\rbac\DbManager::checkAccessRecursive if role assignments are empty (Ni-san)
- Enh #12771: Skip \yii\rbac\PhpManager::checkAccessRecursive and \yii\rbac\DbManager::checkAccessRecursive if role assignments are empty (Ni-san)
- Enh #12790: Added `scrollToErrorOffset` option for `yii\widgets\ActiveForm` which adds ability to specify offset in pixels when scrolling to error (mg-code)
- Enh #12790: Added `scrollToErrorOffset` option for `yii\widgets\ActiveForm` which adds ability to specify offset in pixels when scrolling to error (mg-code)
- Enh #12798: Changed `yii\cache\Dependency::getHasChanged()` (deprecated, to be removed in 2.1) to `yii\cache\Dependency::isChanged()` (dynasource)
- Enh #12798: Changed `yii\cache\Dependency::getHasChanged()` (deprecated, to be removed in 3.0) to `yii\cache\Dependency::isChanged()` (dynasource)
- Enh #12807: Added console controller checks for `yii\console\controllers\HelpController` (schmunk42)
- Enh #12807: Added console controller checks for `yii\console\controllers\HelpController` (schmunk42)
- Enh #12816: Added `columnSchemaClass` option for `yii\db\Schema` which adds ability to specify custom `yii\db\ColumnSchema` class (nanodesu88)
- Enh #12816: Added `columnSchemaClass` option for `yii\db\Schema` which adds ability to specify custom `yii\db\ColumnSchema` class (nanodesu88)
providing ability to setup custom mail headers. Make sure your provide implementation for those methods, while
providing ability to setup custom mail headers. Make sure your provide implementation for those methods, while
creating your own mailer solution.
creating your own mailer solution.
* `::className()` method calls should be replaced with [native](http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class) `::class`.
* `::className()` method calls should be replaced with [native](http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class) `::class`.
When upgrading to Yii 2.1, You should do a global search and replace for `::className()` to `::class`.
When upgrading to Yii 3.0, You should do a global search and replace for `::className()` to `::class`.
All calls on objects via `->className()` should be replaced by a call to `get_class()`.
All calls on objects via `->className()` should be replaced by a call to `get_class()`.
* Dependency injection (DI) layer has been replaced by "yiisoft/di" package. Make sure to update class/object definitions at
* Dependency injection (DI) layer has been replaced by "yiisoft/di" package. Make sure to update class/object definitions at
your code to match the syntax used by it. In particular: you should use '__class' array key instead of 'class' for
your code to match the syntax used by it. In particular: you should use '__class' array key instead of 'class' for
@ -131,9 +131,9 @@ Upgrade from Yii 2.0.x
* Console command used to clear cache now calls related actions "clear" instead of "flush".
* Console command used to clear cache now calls related actions "clear" instead of "flush".
* Yii autoloader was removed in favor of Composer-generated one. You should remove explicit inclusion of `Yii.php` from
* Yii autoloader was removed in favor of Composer-generated one. You should remove explicit inclusion of `Yii.php` from
your entry `index.php` scripts. In case you have relied on class map, use `composer.json` instead of configuring it
your entry `index.php` scripts. In case you have relied on class map, use `composer.json` instead of configuring it
with PHP. For details please refer to [guide on autoloading](https://github.com/yiisoft/yii2/blob/2.1/docs/guide/concept-autoloading.md),
with PHP. For details please refer to [guide on autoloading](https://github.com/yiisoft/yii2/blob/3.0/docs/guide/concept-autoloading.md),
[guide on customizing helpers](https://github.com/yiisoft/yii2/blob/2.1/docs/guide/helper-overview.md#customizing-helper-classes-)
[guide on customizing helpers](https://github.com/yiisoft/yii2/blob/3.0/docs/guide/helper-overview.md#customizing-helper-classes-)
and [guide on Working with Third-Party Code](https://github.com/yiisoft/yii2/blob/2.1/docs/guide/tutorial-yii-integration.md).
and [guide on Working with Third-Party Code](https://github.com/yiisoft/yii2/blob/3.0/docs/guide/tutorial-yii-integration.md).
* The signature of `yii\web\RequestParserInterface::parse()` was changed. The method now accepts the `yii\web\Request` instance
* The signature of `yii\web\RequestParserInterface::parse()` was changed. The method now accepts the `yii\web\Request` instance
as a sole argument. Make sure you declare and implement this method correctly, while creating your own request parser.
as a sole argument. Make sure you declare and implement this method correctly, while creating your own request parser.
* Uploaded file retrieve methods have been moved from `yii\http\UploadedFile` to `yii\web\Request`. You should use `Request::getUploadedFileByName()`
* Uploaded file retrieve methods have been moved from `yii\http\UploadedFile` to `yii\web\Request`. You should use `Request::getUploadedFileByName()`
@ -263,7 +263,7 @@ Upgrade from Yii 2.0.13
* `yii\db\PdoValue` class has been introduced to replace a special syntax that was used to declare PDO parameter type
* `yii\db\PdoValue` class has been introduced to replace a special syntax that was used to declare PDO parameter type
when binding parameters to an SQL command, for example: `['value', \PDO::PARAM_STR]`.
when binding parameters to an SQL command, for example: `['value', \PDO::PARAM_STR]`.
You should use `new PdoValue('value', \PDO::PARAM_STR)` instead. Old syntax will be removed in Yii 2.1.
You should use `new PdoValue('value', \PDO::PARAM_STR)` instead. Old syntax will be removed in Yii 3.0.
* `yii\db\QueryBuilder::conditionBuilders` property and method-based condition builders are no longer used.
* `yii\db\QueryBuilder::conditionBuilders` property and method-based condition builders are no longer used.
Class-based conditions and builders are introduced instead to provide more flexibility, extensibility and
Class-based conditions and builders are introduced instead to provide more flexibility, extensibility and
@ -277,13 +277,13 @@ Upgrade from Yii 2.0.13
* Log targets (like `yii\log\EmailTarget`) are now throwing `yii\log\LogRuntimeException` in case log can not be properly exported.
* Log targets (like `yii\log\EmailTarget`) are now throwing `yii\log\LogRuntimeException` in case log can not be properly exported.
* You can start preparing your application for Yii 2.1 by doing the following:
* You can start preparing your application for Yii 3.0 by doing the following: