This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.
This package is abandoned and no longer maintained. The author suggests using the contao-community-alliance/dependency-container package instead.

Dependency container based on pimple for Contao open source cms.

1.7.0 2015-01-18 10:47 UTC

This package is not auto-updated.

Last update: 2019-02-20 17:27:39 UTC


This DI Container based on Pimple.

Register parameters and services


$container['myservice.param'] = 'value';
$container['myservice'] = function($container) {
	return new MyServiceClassName();

Access parameters and services

class MyClass
	function myFunction()
		global $container;

		$parameter = $container['myservice.param'];
		$service = $container['myservice'];

Build-in services

The config object

/** @var \Config $config */
$config = $container['config'];

The environment object

/** @var \Environment $environment */
$environment = $container['environment'];

The database connection

/** @var \Database $database */
$database = $container['database.connection'];

The input object

/** @var \Input $input */
$input = $container['input'];

The backend or frontend user, depend on TL_MODE

/** @var \BackendUser|\FrontendUser $user */
$user = $container['user'];

The session object

/** @var \Session $session */
$session = $container['session'];

Lazy access to the $objPage object

/** @var DependencyInjection\Container\PageProvider */
$pageProvider = $container['page-provider'];
$page         = $pageProvider->getPage();