<?php
// doctrine-config.php

use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMSetup;

require_once "vendor/autoload.php";
require_once "config.php";

// Pfad zu den Entity-Klassen
$paths = [__DIR__ . "/src/Entity"];
$isDevMode = true;

// Doctrine ORM Konfiguration
$config = ORMSetup::createAttributeMetadataConfiguration($paths, $isDevMode);

// Datenbankverbindungs-Parameter aus config.php
$connectionParams = [
    'driver'   => 'pdo_mysql',
    'host'     => $databaseHost,
    'user'     => $databaseUser,
    'password' => $databasePassword,
    'dbname'   => $databaseDatabase,
    'charset'  => 'utf8mb4',
];

$connection = DriverManager::getConnection($connectionParams, $config);
$entityManager = new EntityManager($connection, $config);

return $entityManager;
