Compare commits
1 Commits
6c41f06105
...
60066746ff
| Author | SHA1 | Date |
|---|---|---|
|
|
60066746ff |
|
|
@ -3,7 +3,7 @@ declare(strict_types=1);
|
|||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use MailAccountAdmin\Config\Loaders\EnvConfigLoader;
|
||||
use MailAccountAdmin\Config\Loaders\AutoConfigLoader;
|
||||
use MailAccountAdmin\Dependencies;
|
||||
use MailAccountAdmin\Middlewares;
|
||||
use MailAccountAdmin\Routes;
|
||||
|
|
@ -11,7 +11,11 @@ use Slim\Factory\AppFactory;
|
|||
|
||||
session_start();
|
||||
|
||||
$config = EnvConfigLoader::loadFromEnv();
|
||||
// Load application config (from environment or config file)
|
||||
$configLoader = new AutoConfigLoader();
|
||||
$config = $configLoader->loadConfig();
|
||||
|
||||
// Create application
|
||||
$container = Dependencies::createContainer($config);
|
||||
$app = AppFactory::createFromContainer($container);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MailAccountAdmin\Config\Loaders;
|
||||
|
||||
use MailAccountAdmin\Config\AppConfig;
|
||||
|
||||
class AutoConfigLoader implements ConfigLoaderInterface
|
||||
{
|
||||
private ConfigLoaderInterface $configLoader;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// TODO determine configloader
|
||||
// (first check if yml file exists, fallback to env?)
|
||||
$this->configLoader = new EnvConfigLoader();
|
||||
}
|
||||
|
||||
public function loadConfig(): AppConfig
|
||||
{
|
||||
return $this->configLoader->loadConfig();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MailAccountAdmin\Config\Loaders;
|
||||
|
||||
use MailAccountAdmin\Config\AppConfig;
|
||||
|
||||
interface ConfigLoaderInterface
|
||||
{
|
||||
public function loadConfig(): AppConfig;
|
||||
}
|
||||
|
|
@ -5,9 +5,9 @@ namespace MailAccountAdmin\Config\Loaders;
|
|||
|
||||
use MailAccountAdmin\Config\AppConfig;
|
||||
|
||||
class EnvConfigLoader
|
||||
class EnvConfigLoader implements ConfigLoaderInterface
|
||||
{
|
||||
public static function loadFromEnv(): AppConfig
|
||||
public function loadConfig(): AppConfig
|
||||
{
|
||||
return AppConfig::createFromArray([
|
||||
// App settings
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MailAccountAdmin\Config\Loaders;
|
||||
|
||||
use MailAccountAdmin\Config\AppConfig;
|
||||
|
||||
class YamlConfigLoader implements ConfigLoaderInterface
|
||||
{
|
||||
private string $filePath;
|
||||
|
||||
public function __construct(string $filePath)
|
||||
{
|
||||
$this->filePath = $filePath;
|
||||
}
|
||||
|
||||
public function loadConfig(): AppConfig
|
||||
{
|
||||
// TODO implement
|
||||
|
||||
return AppConfig::createFromArray([
|
||||
// TODO
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue