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:
2025-08-11 20:13:26 +02:00
parent 59fd3dd3b1
commit 55a330b223
3683 changed files with 2956207 additions and 16948 deletions

View File

@@ -1,16 +1,18 @@
<?php
declare(strict_types=1);
namespace App\Framework\QueryBus;
use App\Framework\DI\DefaultContainer;
use App\Framework\DI\Container;
final readonly class DefaultQueryBus implements QueryBus
{
public function __construct(
private array $eventHandlers,
private DefaultContainer $container
) {}
private Container $container
) {
}
/**
* Dispatcht ein Event an alle registrierten Handler
@@ -18,11 +20,12 @@ final readonly class DefaultQueryBus implements QueryBus
* @param object $event Das zu dispatchende Event
* @return void
*/
public function dispatch(object $event): mixed {
public function dispatch(object $event): mixed
{
$eventClass = get_class($event);
// Prüfe, ob Handler für diesen Event-Typ registriert sind
if (empty($this->eventHandlers) || !isset($this->eventHandlers[$eventClass])) {
if (empty($this->eventHandlers) || ! isset($this->eventHandlers[$eventClass])) {
return null;
}
@@ -41,7 +44,8 @@ final readonly class DefaultQueryBus implements QueryBus
} catch (\Throwable $e) {
// Fehler in Event-Handlern sollten die Anwendung nicht abstürzen lassen
// In einer echten Anwendung würde hier ein Logger verwendet
error_log('Fehler bei der Ausführung des Event-Handlers: ' . $e->getMessage());
// This should use proper logger - for now just comment out
// error_log('Fehler bei der Ausführung des Event-Handlers: ' . $e->getMessage());
}
}
}

View File

@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Framework\QueryBus;
interface QueryBus

View File

@@ -1,22 +1,33 @@
<?php
declare(strict_types=1);
namespace App\Framework\QueryBus;
use App\Framework\DI\Container;
use App\Framework\DI\Initializer;
use App\Framework\Discovery\Results\DiscoveryResults;
use App\Framework\Discovery\Results\DiscoveryRegistry;
final readonly class QueryBusInitializer
{
public function __construct(
private Container $container,
private DiscoveryResults $results
){}
private DiscoveryRegistry $results
) {
}
#[Initializer]
public function __invoke(): QueryBus
{
$handlers = $this->results->get(QueryHandler::class);
$handlerResults = $this->results->attributes->get(QueryHandler::class);
$handlers = [];
foreach ($handlerResults as $discoveredAttribute) {
// Use additionalData instead of mappedData (DiscoveredAttribute)
if ($discoveredAttribute->additionalData) {
$handlers[] = $discoveredAttribute->additionalData;
}
}
return new DefaultQueryBus($handlers, $this->container);
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace App\Framework\QueryBus;
@@ -20,5 +21,6 @@ final readonly class QueryHandler
public function __construct(
public ?int $priority = null,
public bool $stopPropagation = false
) {}
) {
}
}

View File

@@ -1,10 +1,10 @@
<?php
declare(strict_types=1);
namespace App\Framework\QueryBus;
use App\Framework\Core\AttributeCompiler;
use App\Framework\QueryBus\QueryHandler;
/**
* Compiler für Event-Handler
@@ -42,12 +42,12 @@ final readonly class QueryHandlerCompiler implements AttributeCompiler
$stopPropagation = $handler['attribute_data']['stopPropagation'] ?? false;
// Prüfe, ob alle erforderlichen Daten vorhanden sind
if (!$className || !$methodName || !$eventClass) {
if (! $className || ! $methodName || ! $eventClass) {
continue;
}
// Füge den Handler zur Liste der Handler für diesen Event-Typ hinzu
if (!isset($compiledHandlers[$eventClass])) {
if (! isset($compiledHandlers[$eventClass])) {
$compiledHandlers[$eventClass] = [];
}
@@ -55,7 +55,7 @@ final readonly class QueryHandlerCompiler implements AttributeCompiler
'class' => $className,
'method' => $methodName,
'priority' => $priority,
'stopPropagation' => $stopPropagation
'stopPropagation' => $stopPropagation,
];
}

View File

@@ -1,14 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Framework\QueryBus;
use App\Framework\Core\AttributeMapper;
use ReflectionClass;
use ReflectionMethod;
use App\Framework\Reflection\WrappedReflectionClass;
use App\Framework\Reflection\WrappedReflectionMethod;
/**
* Mapper für das EventHandler-Attribut
* Mapper für das QueryHandler-Attribut
*/
final class QueryHandlerMapper implements AttributeMapper
{
@@ -22,14 +23,10 @@ final class QueryHandlerMapper implements AttributeMapper
/**
* Implementiert die map-Methode aus dem AttributeMapper-Interface
*
* @param object $reflectionTarget Das Reflektionsobjekt (ReflectionClass|ReflectionMethod)
* @param object $attributeInstance Die Attributinstanz
* @return array|null Die Attributdaten oder null, wenn nicht verarbeitet werden kann
*/
public function map(object $reflectionTarget, object $attributeInstance): ?array
public function map(WrappedReflectionClass|WrappedReflectionMethod $reflectionTarget, object $attributeInstance): ?array
{
if (!($reflectionTarget instanceof ReflectionMethod)) {
if (! ($reflectionTarget instanceof WrappedReflectionMethod)) {
return null;
}
@@ -41,19 +38,19 @@ final class QueryHandlerMapper implements AttributeMapper
}
$eventType = $parameters[0]->getType();
if (!$eventType || $eventType->isBuiltin()) {
if (! $eventType || $eventType->isBuiltin()) {
return null;
}
$eventClassName = $eventType->getName();
return [
'class' => $reflectionTarget->getDeclaringClass()->getName(),
'class' => $reflectionTarget->getDeclaringClass()->getFullyQualified(),
'method' => $reflectionTarget->getName(),
'event_class' => $eventClassName,
'attribute_data' => [
'priority' => $attributeInstance->priority ?? 0,
'stopPropagation' => $attributeInstance->stopPropagation ?? false
'stopPropagation' => $attributeInstance->stopPropagation ?? false,
],
];
}