Files
mystuff_backend/api/config.php
Lars Behrends 66f69bc90d Add PHP Media API scaffold and Docker configs
Initial project scaffold for a PHP Media API including routing, controllers, models and services under api/ (Router, Media/Cast/Image/Settings controllers, models, database/bootstrap files and automatic docs service). Adds Docker support (Dockerfile, docker-compose.yml, DOCKER_README.md, php-custom.ini), .htaccess for pretty URLs, API documentation and example payloads (API_EXAMPLES.md, api/README.md, api_examples/*.json), image handling service and logging, plus a comprehensive .gitignore. This commit provides a runnable development environment and example requests to get the API up and tested quickly.
2026-04-12 00:46:30 +02:00

40 lines
1.4 KiB
PHP

<?php
// Konfiguration
// Docker-Umgebungsvariablen oder Standardwerte
define('DB_HOST', getenv('DB_HOST') ?: 'mariadb');
define('DB_NAME', getenv('DB_NAME') ?: 'kyoo');
define('DB_USER', getenv('DB_USER') ?: 'kyoo_user');
define('DB_PASS', getenv('DB_PASS') ?: 'kyoo_password');
define('API_BASE', '/api');
// API Logging Konfiguration
define('API_LOGGING_ENABLED', getenv('API_LOGGING_ENABLED') === 'true' || false); // Standardmäßig aktiviert zum Testen
define('API_LOG_FILE', '/var/www/html/logs/api.log');
// PHP Error Logging Konfiguration
define('PHP_ERROR_LOG_FILE', '/var/www/html/logs/php_error.log');
// Hilfsfunktion für cleanname Generierung
function generateCleanName($name) {
// Kleinbuchstaben, nur alphanumerische Zeichen und Bindestriche
$clean = strtolower($name);
// Sonderzeichen durch Bindestriche ersetzen
$clean = preg_replace('/[^a-z0-9]+/', '-', $clean);
// Bindestriche am Anfang und Ende entfernen
$clean = trim($clean, '-');
// Mehrere Bindestriche durch einen ersetzen
$clean = preg_replace('/-+/', '-', $clean);
return $clean;
}
// CORS-Header
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
// OPTIONS-Request behandeln
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}