DI: Built-in Extensions

Package nette/di contains a few built-in extension to DI container.

Decorator Extension

Using Decorator extensions we can add tags or add setup (eg call methods) to all services of given class or implementing given interface.

DI Extension

The DI extension is in charge of the meta-settings of the DI container.

Extensions Extension

Using this extension we can add a more extensions defined in NEON configuration files.

Inject Extension

This extension allows us to use option inject: true, which enables passing dependencies via variables with @inject annotation and inject* methods.

		factory: App\Model\Articles
		inject: true
namespace App\Model;

use Nette\Database\Connection;

class Articles
	/** @var Connection @inject */
	public $connection;

By default is inject attribute enabled only for presenters.

Search Extension

Search extension walks through given directories and registers found classes as services automatically.

Related blog posts