Compare commits
1 Commits
6c41f06105
...
60066746ff
| Author | SHA1 | Date |
|---|---|---|
|
|
60066746ff |
|
|
@ -10,7 +10,6 @@ MYSQL_USER=mailaccountadmin
|
||||||
MYSQL_PASSWORD=mailaccountadmin
|
MYSQL_PASSWORD=mailaccountadmin
|
||||||
|
|
||||||
# App settings
|
# App settings
|
||||||
APP_TITLE="MailAccountAdmin [dev]"
|
|
||||||
APP_ENV=development
|
APP_ENV=development
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_TIMEZONE=Europe/Berlin
|
APP_TIMEZONE=Europe/Berlin
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,5 @@
|
||||||
# PHP
|
# PHP
|
||||||
/.composer
|
/.composer
|
||||||
/.phpunit.cache
|
/.phpunit.cache
|
||||||
/.twig.cache
|
|
||||||
/coverage
|
/coverage
|
||||||
/vendor
|
/vendor
|
||||||
|
|
||||||
# Production settings
|
|
||||||
/config/app.yml
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@ FROM php:7.4-apache AS base
|
||||||
WORKDIR /var/www
|
WORKDIR /var/www
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y git unzip libyaml-dev libzip-dev && \
|
apt-get install -y libzip-dev unzip git && \
|
||||||
docker-php-ext-install pdo pdo_mysql zip && \
|
docker-php-ext-install pdo pdo_mysql zip
|
||||||
pecl install yaml && \
|
|
||||||
docker-php-ext-enable yaml
|
|
||||||
|
|
||||||
RUN a2enmod rewrite && \
|
RUN a2enmod rewrite && \
|
||||||
sed -ri -e 's!/var/www/html!/var/www/public!g' /etc/apache2/sites-available/*.conf
|
sed -ri -e 's!/var/www/html!/var/www/public!g' /etc/apache2/sites-available/*.conf
|
||||||
|
|
|
||||||
2
TODO.md
2
TODO.md
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
## General
|
## General
|
||||||
|
|
||||||
|
- Settings from a config file
|
||||||
- Database migrations
|
- Database migrations
|
||||||
- Documentation
|
- Documentation
|
||||||
- App deployment
|
- App deployment
|
||||||
|
|
@ -11,7 +12,6 @@
|
||||||
- Refactor auth and session handling
|
- Refactor auth and session handling
|
||||||
|
|
||||||
## Admin user management
|
## Admin user management
|
||||||
|
|
||||||
- Create/edit/delete admins
|
- Create/edit/delete admins
|
||||||
- Change own password
|
- Change own password
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.4",
|
"php": "^7.4",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"ext-yaml": "*",
|
|
||||||
"slim/slim": "^4.8",
|
"slim/slim": "^4.8",
|
||||||
"slim/psr7": "^1.3",
|
"slim/psr7": "^1.3",
|
||||||
"php-di/php-di": "^6.3",
|
"php-di/php-di": "^6.3",
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
# Config file for local development (same settings as .env.develop)
|
|
||||||
|
|
||||||
# -- App settings
|
|
||||||
appTitle: "MailAccountAdmin [dev]"
|
|
||||||
environment: development
|
|
||||||
debug: true
|
|
||||||
timezone: Europe/Berlin
|
|
||||||
|
|
||||||
# -- Twig settings
|
|
||||||
twig:
|
|
||||||
cacheDir:
|
|
||||||
|
|
||||||
# -- Database settings
|
|
||||||
database:
|
|
||||||
host: db
|
|
||||||
port: 3306
|
|
||||||
name: mailusers
|
|
||||||
username: mailaccountadmin
|
|
||||||
password: mailaccountadmin
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
# This is an example config file for MailAccountAdmin.
|
|
||||||
# Copy this file to /config/app.yml and change as needed.
|
|
||||||
# Settings that are commented out represent the default values.
|
|
||||||
|
|
||||||
# -- App settings
|
|
||||||
# appTitle: MailAccountAdmin
|
|
||||||
# environment: production
|
|
||||||
# debug: false
|
|
||||||
# timezone: UTC
|
|
||||||
# dateTimeFormat: r
|
|
||||||
|
|
||||||
# -- Twig settings
|
|
||||||
twig:
|
|
||||||
# Cache directory for Twig templates (default: unset, which means no cache is used)
|
|
||||||
cacheDir: .twig.cache
|
|
||||||
|
|
||||||
# -- Database settings
|
|
||||||
database:
|
|
||||||
host: localhost
|
|
||||||
port: 3306
|
|
||||||
name: mailusers
|
|
||||||
username: mailaccountadmin
|
|
||||||
password: very_secret_password
|
|
||||||
|
|
@ -9,11 +9,9 @@ use MailAccountAdmin\Middlewares;
|
||||||
use MailAccountAdmin\Routes;
|
use MailAccountAdmin\Routes;
|
||||||
use Slim\Factory\AppFactory;
|
use Slim\Factory\AppFactory;
|
||||||
|
|
||||||
const ROOT_DIR = __DIR__ . '/..';
|
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
// Load application config (from config file or environment variables)
|
// Load application config (from environment or config file)
|
||||||
$configLoader = new AutoConfigLoader();
|
$configLoader = new AutoConfigLoader();
|
||||||
$config = $configLoader->loadConfig();
|
$config = $configLoader->loadConfig();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,23 +70,10 @@ class AppConfig
|
||||||
return $this->dateTimeFormat;
|
return $this->dateTimeFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTwigCacheDir(): ?string
|
|
||||||
{
|
|
||||||
if (empty($this->twigCacheDir)) {
|
|
||||||
return null;
|
|
||||||
} elseif (substr($this->twigCacheDir, 0, 1) === '/') {
|
|
||||||
// Absolute path
|
|
||||||
return $this->twigCacheDir;
|
|
||||||
} else {
|
|
||||||
// Relative path
|
|
||||||
return ROOT_DIR . '/' . $this->twigCacheDir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTwigSettings(): array
|
public function getTwigSettings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'cache' => $this->getTwigCacheDir() ?: false,
|
'cache' => $this->twigCacheDir ?: false,
|
||||||
'debug' => $this->isDebugMode(),
|
'debug' => $this->isDebugMode(),
|
||||||
'strict_variables' => $this->isDebugMode(),
|
'strict_variables' => $this->isDebugMode(),
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,10 @@ class AutoConfigLoader implements ConfigLoaderInterface
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$yamlFilePath = ROOT_DIR . '/config/app.yml';
|
// TODO determine configloader
|
||||||
|
// (first check if yml file exists, fallback to env?)
|
||||||
// Check if yml config file exists
|
|
||||||
if (file_exists($yamlFilePath)) {
|
|
||||||
$this->configLoader = new YamlConfigLoader($yamlFilePath);
|
|
||||||
} else {
|
|
||||||
$this->configLoader = new EnvConfigLoader();
|
$this->configLoader = new EnvConfigLoader();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function loadConfig(): AppConfig
|
public function loadConfig(): AppConfig
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,38 +11,15 @@ class YamlConfigLoader implements ConfigLoaderInterface
|
||||||
|
|
||||||
public function __construct(string $filePath)
|
public function __construct(string $filePath)
|
||||||
{
|
{
|
||||||
assert(file_exists($filePath));
|
|
||||||
|
|
||||||
$this->filePath = $filePath;
|
$this->filePath = $filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadConfig(): AppConfig
|
public function loadConfig(): AppConfig
|
||||||
{
|
{
|
||||||
// Parse yml config file
|
// TODO implement
|
||||||
$parsedConfig = yaml_parse_file($this->filePath);
|
|
||||||
|
|
||||||
// Check datatypes
|
|
||||||
assert(is_array($parsedConfig));
|
|
||||||
assert(!isset($parsedConfig['twig']) || is_array($parsedConfig['twig']));
|
|
||||||
assert(!isset($parsedConfig['database']) || is_array($parsedConfig['database']));
|
|
||||||
|
|
||||||
return AppConfig::createFromArray([
|
return AppConfig::createFromArray([
|
||||||
// App settings
|
// TODO
|
||||||
'appTitle' => $parsedConfig['appTitle'] ?? null,
|
|
||||||
'environment' => $parsedConfig['environment'] ?? null,
|
|
||||||
'debug' => (bool)$parsedConfig['debug'] ?? null,
|
|
||||||
'timezone' => $parsedConfig['timezone'] ?? null,
|
|
||||||
'dateTimeFormat' => $parsedConfig['dateTimeFormat'] ?? null,
|
|
||||||
|
|
||||||
// Twig settings
|
|
||||||
'twigCacheDir' => $parsedConfig['twig']['cacheDir'] ?? null,
|
|
||||||
|
|
||||||
// Database settings
|
|
||||||
'databaseHost' => $parsedConfig['database']['host'] ?? null,
|
|
||||||
'databasePort' => (int)$parsedConfig['database']['port'] ?? null,
|
|
||||||
'databaseName' => $parsedConfig['database']['name'] ?? null,
|
|
||||||
'databaseUsername' => $parsedConfig['database']['username'] ?? null,
|
|
||||||
'databasePassword' => $parsedConfig['database']['password'] ?? null,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,7 @@
|
||||||
<header>
|
<header>
|
||||||
<h1>{{ app_info.getTitle() }}</h1>
|
<h1>{{ app_info.getTitle() }}</h1>
|
||||||
<div class="header_appversion">
|
<div class="header_appversion">
|
||||||
{% if logged_in | default() %}
|
|
||||||
<a href="{{ app_info.getRepositoryUrl() }}">{{ app_info.getVersion() }}</a>
|
<a href="{{ app_info.getRepositoryUrl() }}">{{ app_info.getVersion() }}</a>
|
||||||
{% else %}
|
|
||||||
{{ app_info.getVersion() }}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="header_spacer"></div>
|
<div class="header_spacer"></div>
|
||||||
<div class="header_userstatus">
|
<div class="header_userstatus">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue