36 lines
725 B
PHP
36 lines
725 B
PHP
|
<?php
|
||
|
namespace App;
|
||
|
|
||
|
use Symfony\Component\Yaml\Yaml;
|
||
|
use Symfony\Component\Yaml\Exception\ParseException;
|
||
|
|
||
|
use Monolog\Logger;
|
||
|
use Monolog\Handler\StreamHandler;
|
||
|
|
||
|
|
||
|
class App {
|
||
|
protected Logger $logger;
|
||
|
protected array $config;
|
||
|
|
||
|
function __construct(string $configFile)
|
||
|
{
|
||
|
$this->config = Yaml::parseFile($configFile);
|
||
|
|
||
|
$logger = new Logger('app');
|
||
|
$logger->pushHandler(new StreamHandler($this->getConfig()['logging']['stream']));
|
||
|
$logger->info("Initialization complete");
|
||
|
|
||
|
$this->logger = $logger;
|
||
|
}
|
||
|
|
||
|
|
||
|
function getConfig() : array
|
||
|
{
|
||
|
return $this->config;
|
||
|
}
|
||
|
|
||
|
function getLogger() : Logger
|
||
|
{
|
||
|
return $this->logger;
|
||
|
}
|
||
|
}
|