Upgrading

Upgrading to Version 3.1

  • autowiring no longer passes null to a nullable parameter without a default value; pass the argument explicitly, or give the parameter a default value
  • support for the @return annotation was dropped; use a return type, or state the type in the service definition using type:
  • the key dynamic was renamed to imported and class to type
  • the symbol for an omitted argument changed from ... to _, e.g. MyService(_, 123)
  • in NEON files, the @ character at the beginning of a string no longer needs to be escaped
  • the parameters key inside definitions of generated factories is deprecated
  • the method Nette\DI\Config\Loader::save() is deprecated; export the configuration using Nette\DI\Config\Adapters\NeonAdapter::dump()

Version 3.1 is a transition release: it does not bring new features, but it warns with notices about everything that will work differently later. See the article Nette DI 3.1: transition release.

Upgrading to Version 3.0

  • support for INI files has been removed
  • direct writing of PHP code into the configuration using question marks (e.g. "$service->onError[] = ?"(...)) was removed; use the array syntax '$onError[]' = [...] instead
  • in configuration files, use factory: PDO(...) instead of class: PDO(...)
  • the nette.presenter tag is no longer used for presenters

For Compiler Extension Authors

While Nette 2.4 internally described every service as Nette\DI\ServiceDefinition, there are now several definition types: Nette\DI\Definitions\ImportedDefinition for imported (dynamic) services, Nette\DI\Definitions\FactoryDefinition for generated interface-based factories, Nette\DI\Definitions\AccessorDefinition for generated accessors, and Nette\DI\Definitions\ServiceDefinition for common services.

Therefore, in addition to ContainerBuilder::addDefinition(), there are several other methods for creating a new definition: addFactoryDefinition(), addAccessorDefinition(), and addImportedDefinition().

Upgrading to Version 2.4

  • configuration sections (e.g. production, development) in a single config file are deprecated; use a pair of files config.neon and config.local.neon
  • inheritance of service definitions is deprecated
  • Statement::setEntity() is deprecated

Upgrading to Version 2.3

  • support for placing services inside the extension section of the configuration file was removed
  • support for dynamically added extensions was removed
  • when replacing a service dynamically (via removeService(), addService()), the new service must be an instance of the same interface/class as the original
version: 3.x