This DI Container based on Pimple.
NOTE on Contao 4: This is obsolete in Contao 4 - you should use the symfony container in Contao 4.
This extension keeps compatibility for easing migration to Contao 4 - however, you should change your code to register your services using both registration ways.
For a howto of how to migrate to Contao 4, please refer to the UPGRADING-TO-CONTAO4.md
system/modules/X/config/services.php
$container['myservice.param'] = 'value';
$container['myservice'] = function($container) {
return new MyServiceClassName();
}
class MyClass
{
function myFunction()
{
global $container;
$parameter = $container['myservice.param'];
$service = $container['myservice'];
}
}
/** @var \Config $config */
$config = $container['config'];
/** @var \Environment $environment */
$environment = $container['environment'];
/** @var \Database $database */
$database = $container['database.connection'];
/** @var \Input $input */
$input = $container['input'];
/** @var \BackendUser|\FrontendUser $user */
$user = $container['user'];
/** @var \Session $session */
$session = $container['session'];
/** @var DependencyInjection\Container\PageProvider */
$pageProvider = $container['page-provider'];
$page = $pageProvider->getPage();