Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,55 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Database;
|
||||
|
||||
use App\Domain\User\User;
|
||||
use App\Framework\Attributes\Singleton;
|
||||
use App\Framework\Core\Events\EventDispatcher;
|
||||
use App\Framework\Database\Cache\EntityCacheManager;
|
||||
use App\Framework\Database\Config\DatabaseConfig;
|
||||
use App\Framework\Database\Config\PoolConfig;
|
||||
use App\Framework\Database\Driver\DriverConfig;
|
||||
use App\Framework\Database\Driver\DriverType;
|
||||
use App\Framework\DateTime\Clock;
|
||||
use App\Framework\DateTime\Timer;
|
||||
use App\Framework\DI\Container;
|
||||
use App\Framework\DI\Initializer;
|
||||
use App\Framework\Logging\Logger;
|
||||
|
||||
final readonly class EntityManagerInitializer
|
||||
{
|
||||
#[Initializer]
|
||||
public function __invoke(Container $container): EntityManager
|
||||
{
|
||||
$config = [
|
||||
'driver' => 'mysql',
|
||||
'host' => 'db',
|
||||
'port' => 3306,
|
||||
'username' => 'mdb-user',
|
||||
'password' => 'dfghreh5465fghfgh',
|
||||
'database' => 'database',
|
||||
];
|
||||
$databaseConfig = $container->get(DatabaseConfig::class);
|
||||
$eventDispatcher = $container->get(EventDispatcher::class);
|
||||
$clock = $container->get(Clock::class);
|
||||
$timer = $container->get(Timer::class);
|
||||
|
||||
$newConfig = new DatabaseConfig(
|
||||
new DriverConfig(
|
||||
driverType: DriverType::MYSQL,
|
||||
host : 'mysql',
|
||||
port : 3306,
|
||||
database : 'database',
|
||||
username : "mdb-user",
|
||||
password : 'dfghreh5465fghfgh',
|
||||
charset : 'utf8mb4',
|
||||
),
|
||||
new PoolConfig(
|
||||
enabled: true,
|
||||
maxConnections: 5,
|
||||
minConnections: 2,
|
||||
),
|
||||
// Get optional dependencies for profiling
|
||||
$logger = null;
|
||||
if ($databaseConfig->profilingConfig->enabled && $container->has(Logger::class)) {
|
||||
$logger = $container->get(Logger::class);
|
||||
}
|
||||
|
||||
$db = new DatabaseManager(
|
||||
$databaseConfig,
|
||||
$timer,
|
||||
'database/migrations',
|
||||
$clock,
|
||||
$logger,
|
||||
$eventDispatcher
|
||||
);
|
||||
|
||||
|
||||
#$connection = DatabaseFactory::createConnection($config);
|
||||
|
||||
$db = new DatabaseManager($config);
|
||||
|
||||
$container->singleton(DatabaseManager::class, $db);
|
||||
$container->singleton(ConnectionInterface::class, $db->getConnection());
|
||||
|
||||
return EntityManagerFactory::create($db);
|
||||
// Only register ConnectionInterface if not already registered
|
||||
if (! $container->has(ConnectionInterface::class)) {
|
||||
// Lazy connection - only create when requested
|
||||
$container->singleton(ConnectionInterface::class, fn () => $db->getConnection());
|
||||
}
|
||||
|
||||
// Get cache manager if caching is enabled
|
||||
$cacheManager = null;
|
||||
if ($databaseConfig->cacheConfig->enabled) {
|
||||
$cacheManager = $container->get(EntityCacheManager::class);
|
||||
}
|
||||
|
||||
return EntityManagerFactory::create($db, $eventDispatcher, $clock, $cacheManager);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user