dev-master
9999999-dev
MIT
The Requires
The Development Requires
1.0.0
1.0.0.0
MIT
The Requires
The Development Requires
Wallogit.com
2017 © Pedro Peláez
Yii2 logger is not PSR3 compatible, therefore when you need logger functionality in third party library (which uses PSR3 logger interface), this package may save your time., (*2)
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
$ php composer.phar require alexeevdv/yii2-psr-log-adapter
or add, (*5)
"alexeevdv/yii2-psr-log-adapter": "^1.0"
to the require section of your composer.json file., (*6)
Lets assume some third party code, (*7)
use Psr\Log\LoggerInterface;
class ThirdParty
{
private $logger;
function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
}
use alexeevdv\yii\PsrLoggerAdapter; $logger = new PsrLoggerAdapter(['category' => 'my-category']); $thirdParty = new ThirdParty($logger);
// Yii application config
[
//...
'container' => [
'definitions' => [
\Psr\Log\LoggerInterface::class => [
'class' => \alexeevdv\yii\PsrLoggerAdapter::class,
'category' => 'my-category',
],
],
],
//...
]
// Lest create third party object now
// Logger adapter will be injected automagically
$thirdParty = Yii::createObject(ThirdParty::class);
By default yii logger is taken from DI container but you can specify your own if you wish., (*8)
use alexeevdv\yii\PsrLoggerAdapter;
$logger = new PsrLoggerAdapter([
'logger' => 'mylogger', // logger configuration here. Anything that can be passed to \yii\di\Instance::ensure
'category' => 'my-category',
]);
MIT
MIT