PHP code example of alexeevdv / yii2-psr-log-adapter
1. Go to this page and download the library: Download alexeevdv/yii2-psr-log-adapter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexeevdv / yii2-psr-log-adapter example snippets
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);
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',
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.