$di->setShared('logger', function () use ($config) {
return new FileAdapter($config->logger->application);
});
$di->setShared('cache', function () use ($config) {
$cache = new Redis();
$res = $cache->connect($config->redis->host,$config->redis->port,$config->redis->lifetime);
//if($res !== true){
// $logger = new FileAdapter(APP_PATH . '/app/runtime/apperror.log');
//$logger->error('redis-connect-error: redis connect result ' . json_encode($res));
//}
$this->logger->error('redis-connect-error: redis connect result ' . json_encode($res));
return $cache;
});
when run php script throw error: PHP Fatal error: Using $this when not in object context