Major additions: - Storage abstraction layer with filesystem and in-memory implementations - Gitea API integration with MCP tools for repository management - Console dialog mode with interactive command execution - WireGuard VPN DNS fix implementation and documentation - HTTP client streaming response support - Router generic result type - Parameter type validator for framework core Framework enhancements: - Console command registry improvements - Console dialog components - Method signature analyzer updates - Route mapper refinements - MCP server and tool mapper updates - Queue job chain and dependency commands - Discovery tokenizer improvements Infrastructure: - Deployment architecture documentation - Ansible playbook updates for WireGuard client regeneration - Production environment configuration updates - Docker Compose local configuration updates - Remove obsolete docker-compose.yml (replaced by environment-specific configs) Documentation: - PERMISSIONS.md for access control guidelines - WireGuard DNS fix implementation details - Console dialog mode usage guide - Deployment architecture overview Testing: - Multi-purpose attribute tests - Gitea Actions integration tests (typed and untyped)
132 lines
3.4 KiB
Markdown
132 lines
3.4 KiB
Markdown
# Console-Modul
|
|
|
|
Dieses Modul bietet eine flexible und benutzerfreundliche Konsolen-Schnittstelle für Ihre PHP-Anwendung. Es ermöglicht die Erstellung von CLI-Befehlen mit einfacher Eingabe- und Ausgabehandlung.
|
|
|
|
## Interaktive Modi
|
|
|
|
Das Console-Modul bietet zwei interaktive Modi:
|
|
|
|
### TUI (Text User Interface) - Standard
|
|
|
|
Grafische Terminal-UI mit Maus-Unterstützung und Navigation:
|
|
|
|
```bash
|
|
php console.php # Startet TUI (Standard)
|
|
php console.php --interactive # Startet TUI explizit
|
|
php console.php --tui # Startet TUI explizit
|
|
```
|
|
|
|
### Dialog-Modus - AI-Assistent-ähnlich
|
|
|
|
Einfache Prompt-Eingabe mit Tab-Completion und History:
|
|
|
|
```bash
|
|
php console.php --dialog # Startet Dialog-Modus
|
|
php console.php --chat # Startet Dialog-Modus (Alias)
|
|
```
|
|
|
|
**Weitere Informationen**: Siehe [Console Dialog Mode Dokumentation](../../docs/console-dialog-mode.md)
|
|
|
|
## Hauptkomponenten
|
|
|
|
### ConsoleApplication
|
|
|
|
Die zentrale Klasse zur Verwaltung und Ausführung von Konsolen-Befehlen.
|
|
|
|
```php
|
|
$app = new ConsoleApplication('app', 'Meine Anwendung');
|
|
$app->registerCommands(new MyCommands());
|
|
$app->run($argv);
|
|
```
|
|
|
|
### ConsoleCommand-Attribut
|
|
|
|
Verwenden Sie das `ConsoleCommand`-Attribut, um Methoden als Konsolenbefehle zu kennzeichnen:
|
|
|
|
```php
|
|
class MyCommands
|
|
{
|
|
#[ConsoleCommand(name: 'hello', description: 'Gibt eine Begrüßung aus')]
|
|
public function sayHello(ConsoleInput $input, ConsoleOutput $output): int
|
|
{
|
|
$name = $input->getArgument(0, 'Welt');
|
|
$output->writeLine("Hallo, {$name}!", ConsoleColor::BRIGHT_GREEN);
|
|
return 0;
|
|
}
|
|
}
|
|
```
|
|
|
|
### ConsoleInput und ConsoleOutput
|
|
|
|
Diese Klassen bieten Methoden für die Ein- und Ausgabe in der Konsole:
|
|
|
|
```php
|
|
// Eingabe
|
|
$name = $input->ask('Wie heißen Sie?');
|
|
$confirm = $input->confirm('Fortfahren?', true);
|
|
$option = $input->getOption('verbose');
|
|
|
|
// Ausgabe
|
|
$output->writeSuccess('Operation erfolgreich!');
|
|
$output->writeError('Fehler aufgetreten!');
|
|
$output->writeInfo('Wussten Sie schon...');
|
|
```
|
|
|
|
## Fortschrittsanzeigen
|
|
|
|
### ProgressBar
|
|
|
|
Zeigt eine Fortschrittsanzeige für Operationen mit bekannter Länge:
|
|
|
|
```php
|
|
$total = count($items);
|
|
$progress = new ProgressBar($output, $total);
|
|
$progress->start();
|
|
|
|
foreach ($items as $item) {
|
|
// Verarbeite $item
|
|
$progress->advance();
|
|
}
|
|
|
|
$progress->finish();
|
|
```
|
|
|
|
### Spinner
|
|
|
|
Zeigt einen animierten Spinner für Operationen unbekannter Länge:
|
|
|
|
```php
|
|
$spinner = new Spinner($output, 'Lade Daten...');
|
|
$spinner->start();
|
|
|
|
// Ausführung der Operation
|
|
do {
|
|
// Arbeit ausführen
|
|
$spinner->update();
|
|
} while (!$finished);
|
|
|
|
$spinner->success('Daten erfolgreich geladen!');
|
|
```
|
|
|
|
## Beispiele
|
|
|
|
Sehen Sie sich die Beispielklassen im `Examples`-Verzeichnis an, um mehr über die Verwendung der Komponenten zu erfahren:
|
|
|
|
- `ProgressBarExample`: Zeigt verschiedene Konfigurationen der Fortschrittsanzeige
|
|
- `SpinnerExample`: Demonstriert die Verwendung von Spinnern mit verschiedenen Stilen
|
|
|
|
## Anpassung
|
|
|
|
Sie können die Anzeige anpassen, indem Sie benutzerdefinierte Formatierungen und Farben verwenden:
|
|
|
|
```php
|
|
$progress->setFormat('%bar% %percent%%');
|
|
$progress->setBarCharacters('█', '░', '█');
|
|
|
|
$spinner = new Spinner($output, 'Lade...', SpinnerStyle::BOUNCE);
|
|
```
|
|
|
|
## Fehlerbehebung
|
|
|
|
Wenn Probleme mit der Anzeige auftreten, stellen Sie sicher, dass Ihr Terminal ANSI-Escape-Sequenzen unterstützt. Die meisten modernen Terminals tun dies, aber Windows-Terminals können Einschränkungen haben.
|