Last active
September 30, 2019 19:33
-
-
Save lafraga93/d09ef317c4b6200ff85cc39700ecfcb9 to your computer and use it in GitHub Desktop.
Example 03 - DI com PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Example; | |
use Monolog\Handler\StreamHandler; | |
use Monolog\Logger; | |
use Psr\Log\LoggerInterface; | |
final class ThirdExample | |
{ | |
/** | |
* @var LoggerInterface | |
*/ | |
private $logger; | |
public function __construct(LoggerInterface $logger) | |
{ | |
$this->logger = $logger; | |
} | |
public function something(): void | |
{ | |
//... | |
$this->logger->debug('third example debug description'); | |
} | |
} | |
$logger = new Logger('My_Logger', [ | |
new StreamHandler('logs/debug.log', Logger::DEBUG), | |
]); | |
$controller = new ThirdExample($logger); | |
$controller->something(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment