Add project files

This commit is contained in:
Frank Woeckener
2025-03-18 10:42:10 +01:00
parent e429c37f62
commit fe93319d2a
29 changed files with 816 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace App;
class Database
{
private array $config;
public function __construct(array $config)
{
$this->config = $config;
}
public function testConnection(): bool
{
try {
$dsn = sprintf(
'mysql:host=%s;dbname=%s',
$this->config['host'],
$this->config['name']
);
$options = [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_TIMEOUT => 5,
];
$pdo = new \PDO(
$dsn,
$this->config['user'],
$this->config['pass'],
$options
);
return true;
} catch (\PDOException $e) {
// In einer realen Anwendung würde hier geloggt werden
return false;
}
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App;
class HelloWorld
{
public function getMessage(): string
{
return 'Hallo Welt! Die PHP-Anwendung läuft in Docker.';
}
}