Console Commands
Übersicht aller verfügbaren Console Commands für die Appiyon-Plattform.
Symfony Standard Commands
Cache
bash
# Cache leeren
php bin/console cache:clear
# Cache warmup
php bin/console cache:warmup
# Cache-Pool leeren
php bin/console cache:pool:clear cache.appDoctrine
bash
# Datenbank erstellen
php bin/console doctrine:database:create
# Datenbank löschen
php bin/console doctrine:database:drop --force
# Schema erstellen
php bin/console doctrine:schema:create
# Schema aktualisieren
php bin/console doctrine:schema:update --force
# Schema validieren
php bin/console doctrine:schema:validateMigrations
bash
# Migration-Diff erstellen (automatisch)
php bin/console doctrine:migrations:diff
# Migration manuell erstellen
php bin/console doctrine:migrations:generate
# Alle Migrations ausführen
php bin/console doctrine:migrations:migrate
# Migrations-Status anzeigen
php bin/console doctrine:migrations:status
# Letzte Migration rückgängig
php bin/console doctrine:migrations:migrate prev
# Zu bestimmter Version migrieren
php bin/console doctrine:migrations:migrate DoctrineMigrations\\Infrastructure\\Version0001Debug
bash
# Services anzeigen
php bin/console debug:container
# Routes anzeigen
php bin/console debug:router
# Event Listeners anzeigen
php bin/console debug:event-dispatcher
# Config anzeigen
php bin/console debug:config frameworkAppiyon Custom Commands
Admin Management
admin:create
Erstellt einen neuen System-Administrator.
Interaktiver Modus:
bash
php bin/console admin:createSie werden nach Name, Email und Password gefragt. Das Passwort wird versteckt eingegeben.
Non-Interaktiver Modus:
bash
php bin/console admin:create \
--name="Super Admin" \
--email="admin@example.com" \
--password="SecureP@ss123"Parameter:
--name: Name des Administrators (erforderlich in non-interactive mode)--email: Email-Adresse (erforderlich, wird validiert)--password: Passwort (erforderlich, min. 8 Zeichen, mind. 1 Großbuchstabe, 1 Kleinbuchstabe, 1 Ziffer)
Ausgabe:
Admin successfully created:
- ID: 1
- Name: Super Admin
- Email: admin@example.com
- Created: 2025-10-24 20:26:35Fehlerbehandlung:
- Email bereits vergeben → Error
- Ungültiges Passwort-Format → Error mit Details
- Ungültige Email → Error
Beispiele:
bash
# Interaktiv mit versteckter Passworteingabe
php bin/console admin:create
# Direkt mit allen Parametern
php bin/console admin:create --name="John Doe" --email="john@example.com" --password="MySecret123!"
# Mit Hilfe
php bin/console admin:create --helpGeplante Commands
Folgende Commands sind in Planung:
admin:list
bash
# Alle Admins auflisten
php bin/console admin:list
# Nur aktive Admins
php bin/console admin:list --active
# Mit Details
php bin/console admin:list --verboseadmin:delete
bash
# Admin soft-delete
php bin/console admin:delete admin@example.com
# Admin wiederherstellen
php bin/console admin:restore admin@example.com
# Permanent löschen
php bin/console admin:delete admin@example.com --permanentadmin:password-reset
bash
# Password-Reset-Token erstellen
php bin/console admin:password-reset admin@example.com
# Password direkt setzen (für Recovery)
php bin/console admin:password-reset admin@example.com --new-password="NewSecure123!"audit:export
bash
# Audit-Logs exportieren
php bin/console audit:export --from="2025-01-01" --to="2025-12-31" --format=csv
# Nach Admin filtern
php bin/console audit:export --admin-id=1
# Nach Action filtern
php bin/console audit:export --action="app.approved"tenant:create
bash
# Neuen Tenant erstellen
php bin/console tenant:create "Company Name"app:import
bash
# Apps aus CSV importieren
php bin/console app:import /path/to/apps.csv
# Mit Dry-Run
php bin/console app:import /path/to/apps.csv --dry-runCommand erstellen
Basis-Template
php
<?php
declare(strict_types=1);
namespace App\Appi\Dev\Console\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(
name: 'app:my-command',
description: 'Does something useful',
)]
final class MyCommand extends Command
{
public function __construct()
{
parent::__construct();
}
protected function configure(): void
{
$this
->addArgument('name', InputArgument::REQUIRED, 'The name')
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force the operation');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$name = $input->getArgument('name');
$force = $input->getOption('force');
try {
// Business Logic hier
$io->success('Operation completed successfully');
return Command::SUCCESS;
} catch (\Exception $e) {
$io->error($e->getMessage());
return Command::FAILURE;
}
}
}Registration
Commands werden automatisch registriert durch:
yaml
# config/services.yaml
App\Appi\Dev\Console\Command\:
resource: '../src/Appi/Dev/Console/Command'
tags: ['console.command']Best Practices
- SymfonyStyle nutzen für konsistente Formatierung
- Confirmation bei kritischen Operationen
- Dry-Run Option für Preview
- Verbose Output für Debugging
- Exit Codes:
Command::SUCCESS(0) oderCommand::FAILURE(1) - Exception Handling mit Try-Catch
- Progress Bar bei langen Operationen
Beispiel mit Confirmation
php
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
if (!$input->getOption('force')) {
if (!$io->confirm('This will delete all data. Continue?', false)) {
$io->note('Operation cancelled');
return Command::SUCCESS;
}
}
// Operation durchführen
}Beispiel mit Progress Bar
php
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$items = $this->getItems();
$progressBar = $io->createProgressBar(count($items));
$progressBar->start();
foreach ($items as $item) {
$this->processItem($item);
$progressBar->advance();
}
$progressBar->finish();
$io->newLine();
$io->success('All items processed');
return Command::SUCCESS;
}Testing Commands
php
// tests/Functional/Command/AdminCreateCommandTest.php
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;
class AdminCreateCommandTest extends KernelTestCase
{
public function testExecute(): void
{
$kernel = static::createKernel();
$application = new Application($kernel);
$command = $application->find('admin:create');
$commandTester = new CommandTester($command);
$commandTester->execute([
'--name' => 'Test Admin',
'--email' => 'test@example.com',
'--password' => 'SecureP@ss123',
]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Admin successfully created', $output);
$this->assertEquals(Command::SUCCESS, $commandTester->getStatusCode());
}
}