Nette Documentation Preview

syntax
Migrating to Version 3.1
************************

Minimum required PHP version is 7.2.

All name changes mentioned in this document mean that the original name obviously still exists and works, it is just marked as deprecated. You may encounter the IDE visually marking them as deprecated.

Nette version 3.1 means that you have these packages installed in version 3.1.*. Other packages may have higher or lower version numbers, compatibility is ensured by Composer.

```json
"require": {
	"nette/application": "3.1.*",
	"nette/bootstrap": "3.1.*",
	"nette/caching": "3.1.*",
	"nette/database": "3.1.*",
	"nette/forms": "3.1.*",
	"nette/http": "3.1.*",
	"nette/security": "3.1.*",
},
```


Interface Names
---------------

Nette has been gradually removing the `I` prefix from interface names for a long time, for example `Nette\Security\IAuthenticator` is changed to `Authenticator` etc. In Nette 3.1, the prefix has disappeared from the names of these interfaces:

- `Nette\Application\IRouter`, `Nette\Application\IResponse`, `Nette\Application\UI\IRenderable`, `Nette\Application\UI\ISignalReceiver`, `Nette\Application\UI\IStatePersistent`, `Nette\Application\UI\ITemplate`, `Nette\Application\UI\ITemplateFactory`, `Nette\Bridges\ApplicationLatte\ILatteFactory`
- `Nette\Caching\IStorage`, `Nette\Caching\IBulkReader`, `Nette\Caching\Storages\IJournal`
- `Nette\Database\IConventions`, `Nette\Database\ISupplementalDriver` (now `Nette\Database\Driver`)
- `Nette\Mail\IMailer`
- `Latte\ILoader`, `Latte\Runtime\IHtmlString` (now `Latte\Runtime\HtmlStringable`), `Latte\Runtime\ISnipperDriver`, `Latte\IMacro`
- `Nette\Security\IAuthenticator` *), `Nette\Security\IAuthorizator`, `Nette\Security\IResource`, `Nette\Security\IRole`, `Nette\Security\IUserStorage` *)
- `Nette\Utils\IHtmlString` (now `Nette\HtmlStringable`), `Nette\Localization\ITranslator`

*) interface with prefix is different than without prefix


Bootstrap
---------
- the `Nette\Configurator` class has been renamed to `Nette\Bootstrap\Configurator` to be consistent with the rest of the framework
- added method `addStaticParameters()` as alias for `addParameters()`
- in parameters passed by the `addStaticParameters()` or `addParameters()` method the `%parameters%` are no longer expanded


Caching
-------
- renamed method `Nette\Caching\Cache::start()` -> `capture()`


Database
--------
- renamed class `Nette\Database\Context` -> `Nette\Database\Explorer` to be consistent with the name [Database Explorer|/database/explorer]
- interfaces `Nette\Database\IRow` and `Nette\Database\IRowContainer` are marked as deprecated for uselessness
- MySqlDriver driver uses subqueries
- SQL statement translator better controls where arrays can be passed


Http
----
- cookies are sent with the flag `sameSite: Lax`
- `cookieSecure` is now by default 'auto'
- option `session.cookieSecure` is deprecated, `http.cookieSecure` is used instead
- cookie `nette-samesite` renamed to `_nss`

- `Nette\Http\Request::getFile()` accepts array of keys and returns FileUpload|null
- `Nette\Http\Session::getCookieParameters()` is deprecated
- `Nette\Http\FileUpload::getName()` renamed to `getUntrustedName()`
- `Nette\Http\Url`: deprecated getBasePath(), getBaseUrl(), getRelativeUrl() (tyto metody jsou součástí `UrlScript`)
- `Nette\Http\Response::$cookieHttpOnly` is deprecated
- `Nette\Http\FileUpload::getImageSize()` returns pair `[width, height]`


Neon
----
- Decoder: works in UTF-8 mode, throws exception on invalid input
- syntax `\xAA` is deprecated in favor of `\uAAAA`


Security
--------
- interface `Nette\Security\Authenticator` differs from `IAuthenticator` by the signature of the `authenticate(string $user, string $password)` method
- interface `Nette\Security\UserStorage` differs from `Nette\Security\IUserStorage`
- renamed the class `Nette\Security\Identity` -> `Nette\Security\SimpleIdentity` so that in the distant future the interface `Nette\Security\IIdentity` can be renamed to `Identity`


Utils
-----
- `Nette\Utils\Arrays::searchKey()` renamed to `getKeyOffset()`
- `Nette\Utils\Callback::closure()` is deprecated in favor of `Closure::fromCallable()`
- `Nette\Utils\Reflection::toString()` appends `()` after function/method name
- `Nette\Utils\Strings::toAscii()` triggers notice when ext-intl is not present

{{priority: -5}}

Migrating to Version 3.1

Minimum required PHP version is 7.2.

All name changes mentioned in this document mean that the original name obviously still exists and works, it is just marked as deprecated. You may encounter the IDE visually marking them as deprecated.

Nette version 3.1 means that you have these packages installed in version 3.1.*. Other packages may have higher or lower version numbers, compatibility is ensured by Composer.

"require": {
	"nette/application": "3.1.*",
	"nette/bootstrap": "3.1.*",
	"nette/caching": "3.1.*",
	"nette/database": "3.1.*",
	"nette/forms": "3.1.*",
	"nette/http": "3.1.*",
	"nette/security": "3.1.*",
},

Interface Names

Nette has been gradually removing the I prefix from interface names for a long time, for example Nette\Security\IAuthenticator is changed to Authenticator etc. In Nette 3.1, the prefix has disappeared from the names of these interfaces:

  • Nette\Application\IRouter, Nette\Application\IResponse, Nette\Application\UI\IRenderable, Nette\Application\UI\ISignalReceiver, Nette\Application\UI\IStatePersistent, Nette\Application\UI\ITemplate, Nette\Application\UI\ITemplateFactoryNette\Bridges\ApplicationLatte\ILatteFactory
  • Nette\Caching\IStorage, Nette\Caching\IBulkReader, Nette\Caching\Storages\IJournal
  • Nette\Database\IConventions, Nette\Database\ISupplementalDriver (now Nette\Database\Driver)
  • Nette\Mail\IMailer
  • Latte\ILoader, Latte\Runtime\IHtmlString (now Latte\Runtime\HtmlStringable), Latte\Runtime\ISnipperDriverLatte\IMacro
  • Nette\Security\IAuthenticator *), Nette\Security\IAuthorizator, Nette\Security\IResource, Nette\Security\IRole, Nette\Security\IUserStorage *)
  • Nette\Utils\IHtmlString (now Nette\HtmlStringable), Nette\Localization\ITranslator

*) interface with prefix is different than without prefix

Bootstrap

  • the Nette\Configurator class has been renamed to Nette\Bootstrap\Configurator to be consistent with the rest of the framework
  • added method addStaticParameters() as alias for addParameters()
  • in parameters passed by the addStaticParameters() or addParameters() method the %parameters% are no longer expanded

Caching

  • renamed method Nette\Caching\Cache::start()capture()

Database

  • renamed class Nette\Database\ContextNette\Database\Explorer to be consistent with the name Database Explorer
  • interfaces Nette\Database\IRow and Nette\Database\IRowContainer are marked as deprecated for uselessness
  • MySqlDriver driver uses subqueries
  • SQL statement translator better controls where arrays can be passed

Http

  • cookies are sent with the flag sameSite: Lax
  • cookieSecure is now by default ‚auto‘
  • option session.cookieSecure is deprecated, http.cookieSecure is used instead
  • cookie nette-samesite renamed to _nss
  • Nette\Http\Request::getFile() accepts array of keys and returns FileUpload|null
  • Nette\Http\Session::getCookieParameters() is deprecated
  • Nette\Http\FileUpload::getName() renamed to getUntrustedName()
  • Nette\Http\Url: deprecated getBasePath(), getBaseUrl(), getRelativeUrl() (tyto metody jsou součástí UrlScript)
  • Nette\Http\Response::$cookieHttpOnly is deprecated
  • Nette\Http\FileUpload::getImageSize() returns pair [width, height]

Neon

  • Decoder: works in UTF-8 mode, throws exception on invalid input
  • syntax \xAA is deprecated in favor of \uAAAA

Security

  • interface Nette\Security\Authenticator differs from IAuthenticator by the signature of the authenticate(string $user, string $password) method
  • interface Nette\Security\UserStorage differs from Nette\Security\IUserStorage
  • renamed the class Nette\Security\IdentityNette\Security\SimpleIdentity so that in the distant future the interface Nette\Security\IIdentity can be renamed to Identity

Utils

  • Nette\Utils\Arrays::searchKey() renamed to getKeyOffset()
  • Nette\Utils\Callback::closure() is deprecated in favor of Closure::fromCallable()
  • Nette\Utils\Reflection::toString() appends () after function/method name
  • Nette\Utils\Strings::toAscii() triggers notice when ext-intl is not present