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,4 +1,5 @@
<?php
declare(strict_types=1);
namespace App\Framework\Console;
@@ -6,7 +7,8 @@ namespace App\Framework\Console;
use App\Framework\Console\Components\InteractiveMenu;
use App\Framework\Console\Exceptions\CommandNotFoundException;
use App\Framework\DI\Container;
use App\Framework\Discovery\Results\DiscoveryResults;
use App\Framework\Discovery\Results\DiscoveryRegistry;
use App\Framework\Discovery\ValueObjects\DiscoveredAttribute;
use ReflectionClass;
use ReflectionMethod;
use Throwable;
@@ -14,6 +16,7 @@ use Throwable;
final class ConsoleApplication
{
private array $commands = [];
private ConsoleOutputInterface $output;
public function __construct(
@@ -21,22 +24,33 @@ final class ConsoleApplication
private readonly string $scriptName = 'console',
private readonly string $title = 'Console Application',
?ConsoleOutputInterface $output = null,
) {
$this->output = $output ?? new ConsoleOutput();
// Setze den Fenstertitel
$this->output->writeWindowTitle($this->title);
$results = $this->container->get(DiscoveryResults::class);
$registry = $this->container->get(DiscoveryRegistry::class);
foreach($results->get(ConsoleCommand::class) as $command) {
/** @var DiscoveredAttribute $discoveredAttribute */
foreach ($registry->attributes->get(ConsoleCommand::class) as $discoveredAttribute) {
$this->commands[$command['attribute_data']['name']] = [
'instance' => $this->container->get($command['class']),
'method' => $command['method'],
'description' => $command['attribute_data']['description'] ?? ['Keine Beschreibung verfügbar'],
'reflection' => new ReflectionMethod($command['class'], $command['method'])
/** @var ConsoleCommand $command */
$command = $discoveredAttribute->createAttributeInstance();
// Extract attribute data and class name from Value Object
$attributeData = $discoveredAttribute->arguments ?? [];
$className = $discoveredAttribute->className->getFullyQualified();
if ($command->name === '') {
continue; // Skip commands without proper attribute data
}
$this->commands[$command->name] = [
'instance' => $this->container->get($className),
'method' => $discoveredAttribute->methodName?->toString() ?? '__invoke',
'description' => $attributeData['description'] ?? 'Keine Beschreibung verfügbar',
'reflection' => new ReflectionMethod($className, $discoveredAttribute->methodName?->toString() ?? '__invoke'),
];
}
}
@@ -44,7 +58,6 @@ final class ConsoleApplication
/**
* Registriert alle Kommandos aus einer Klasse
*/
public function registerCommands(object $commandClass): void
{
$reflection = new ReflectionClass($commandClass);
@@ -60,13 +73,12 @@ final class ConsoleApplication
'instance' => $commandClass,
'method' => $method->getName(),
'description' => $command->description,
'reflection' => $method
'reflection' => $method,
];
}
}
}
/**
* Führt ein Kommando aus
*/
@@ -74,6 +86,7 @@ final class ConsoleApplication
{
if (count($argv) < 2) {
$this->showHelp();
return ExitCode::SUCCESS->value;
}
@@ -82,12 +95,14 @@ final class ConsoleApplication
if (in_array($commandName, ['help', '--help', '-h'])) {
$this->showHelp();
return ExitCode::SUCCESS->value;
}
if (!isset($this->commands[$commandName])) {
if (! isset($this->commands[$commandName])) {
$this->output->writeError("Kommando '{$commandName}' nicht gefunden.");
$this->showHelp();
return ExitCode::COMMAND_NOT_FOUND->value;
}
@@ -124,6 +139,7 @@ final class ConsoleApplication
} catch (CommandNotFoundException $e) {
$this->output->writeError("Kommando nicht gefunden: " . $e->getMessage());
return ExitCode::COMMAND_NOT_FOUND;
} catch (Throwable $e) {
$this->output->writeError("Fehler beim Ausführen des Kommandos: " . $e->getMessage());
@@ -149,6 +165,10 @@ final class ConsoleApplication
$menu = new InteractiveMenu($this->output);
$menu->setTitle("Kommandos");
if (empty($this->commands)) {
// TODO Add Default Commands
}
foreach ($this->commands as $name => $command) {
$description = $command['description'] ?: 'Keine Beschreibung verfügbar';