Last active
September 30, 2019 19:35
-
-
Save lafraga93/11a1abc30101b9de9242e33c572202b5 to your computer and use it in GitHub Desktop.
Example 01 - 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; | |
final class FirstExample | |
{ | |
/** | |
* @var Logger | |
*/ | |
private $logger; | |
public function __construct() | |
{ | |
$this->logger = new Logger('My_Logger', [ | |
new StreamHandler('logs/debug.log', Logger::DEBUG), | |
]); | |
} | |
public function something(): void | |
{ | |
//... | |
$this->logger->debug('first example debug description'); | |
} | |
} | |
$controller = new FirstExample(); | |
$controller->something(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment