- Add comprehensive health check system with multiple endpoints - Add Prometheus metrics endpoint - Add production logging configurations (5 strategies) - Add complete deployment documentation suite: * QUICKSTART.md - 30-minute deployment guide * DEPLOYMENT_CHECKLIST.md - Printable verification checklist * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference * production-logging.md - Logging configuration guide * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation * README.md - Navigation hub * DEPLOYMENT_SUMMARY.md - Executive summary - Add deployment scripts and automation - Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment - Update README with production-ready features All production infrastructure is now complete and ready for deployment.
63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\Database;
|
|
|
|
use App\Framework\Core\Events\EventDispatcher;
|
|
use App\Framework\Database\Cache\EntityCacheManager;
|
|
use App\Framework\Database\Config\DatabaseConfig;
|
|
use App\Framework\Database\Platform\MySQLPlatform;
|
|
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
|
|
{
|
|
$databaseConfig = $container->get(DatabaseConfig::class);
|
|
$eventDispatcher = $container->get(EventDispatcher::class);
|
|
$clock = $container->get(Clock::class);
|
|
$timer = $container->get(Timer::class);
|
|
|
|
// Get optional dependencies for profiling
|
|
$logger = null;
|
|
if ($databaseConfig->profilingConfig->enabled && $container->has(Logger::class)) {
|
|
$logger = $container->get(Logger::class);
|
|
}
|
|
|
|
// Create platform for the database (defaulting to MySQL)
|
|
$platform = new MySQLPlatform();
|
|
|
|
$db = new DatabaseManager(
|
|
$databaseConfig,
|
|
$platform,
|
|
$timer,
|
|
'database/migrations',
|
|
$clock,
|
|
$logger,
|
|
$eventDispatcher
|
|
);
|
|
|
|
$container->singleton(DatabaseManager::class, $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, $container, $cacheManager);
|
|
}
|
|
}
|