I have a logger class (Application\Debug\Logger) for logging various debug messages from whole application to log files. And I would like to get instance of that class using simple alias 'logger'. So I try to configure Zend\Di\Di, so that I could do something like this in, for example, module controller or another application components:
$di = new \Zend\Di\Di();
$logger = $di->get('logger');
//$logger should be Application\Debug\Logger instance...
To achieve this, I have this in Application/config/module.config.php:
'di' => array(
'instance' => array(
'alias' => array(
'logger' => 'Application\Debug\Logger',
),
),
)
But the problem is: alias 'logger' doesn`t work. I can use Di and get class by full name (Application\Debug\Logger), but not by alias (I get error: Class logger could not be located in provided definitions). I suppose that I have to pass the configuration to Di somehow, but I don't know how. Can you help me?