Existing systems used to have no automatic mechanism for the db/updates/*.sql idempotent updates after `git pull` — devs had to remember which files were already applied and run new ones manually with `mariadb < ...`. Mirror module:migrate to fix this: - New `bin/console db:migrate` walks db/updates/*.sql in alphabetical order, skipping anything already recorded in the new core_migrations tracking table. Each file runs in its own transaction; failure rolls back so the file is retried on the next run. - New `db:migrate --status` lists applied vs. pending files without running anything. Useful for ops debugging "schema seems stale" symptoms. - module:sync now runs db:migrate as its first step, so the standard post-pull command stays a single invocation. README's 3-step setup is unchanged — module:sync now also covers core schema updates. CoreMigrationRepository owns its own mysqli connection (using the same DB credentials as MintyPHP\DB) and runs raw `$mysqli->query()` instead of going through DB::query's prepared statement path — MariaDB rejects some DDL (e.g. ALTER TABLE … ADD CONSTRAINT CHECK) in the prepared protocol, which the existing 18 db/updates files trip on. ModuleMigrationRepository is left untouched (no module migration uses such DDL today and changing the vendor pattern is out of scope). End-to-end verified: against an existing DB the first run applies all 19 idempotent files as no-ops and records them, second run reports "all updates already applied". Against a freshly init'd DB the same thing happens — no double work, no surprises. All encrypted seed secrets keep decrypting because APP_CRYPTO_KEY is unchanged. Tests: tests/Console/CoreCommandsTest covers success/failure/status output shapes against a FakeModuleRunner (mirror of the existing ModuleCommandsTest pattern). 5 stale baseline entries in phpstan-baseline removed (covered by the new @api annotation on the test fixture class). Docs: CLAUDE.md and docs/reference-cli-commands.md document the new command + --status flag; docs/howto-fehlerbehebung.md gains a "schema seems stale after git pull" section pointing at db:migrate --status. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
209 lines
5.4 KiB
Markdown
209 lines
5.4 KiB
Markdown
# CLI-Kommandoreferenz
|
|
|
|
Letzte Aktualisierung: 2026-04-01
|
|
|
|
## Einstiegspunkt
|
|
|
|
Alle CLI-Kommandos laufen ueber einen einzigen Einstiegspunkt:
|
|
|
|
```bash
|
|
php bin/console <command> [argumente] [optionen]
|
|
```
|
|
|
|
Uebersicht aller verfuegbaren Kommandos:
|
|
|
|
```bash
|
|
php bin/console list
|
|
```
|
|
|
|
Hilfe zu einem einzelnen Kommando:
|
|
|
|
```bash
|
|
php bin/console <command> --help
|
|
```
|
|
|
|
## Kommandos
|
|
|
|
### module:sync
|
|
|
|
Fuehrt den vollstaendigen Runtime-Sync aus: `db-migrate` → `migrate` → `permissions-sync` → `build` → `assets-sync`.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console module:sync
|
|
```
|
|
|
|
Noetig nach jeder Aenderung an Modulen, Manifesten, Routen oder `APP_ENABLED_MODULES` — und nach jedem `git pull`, der Schema-Updates unter `db/updates/*.sql` mitbringt.
|
|
|
|
Falls `web/index.php` den Fehler "Module runtime is stale" wirft, ist dieser Befehl die Loesung.
|
|
|
|
Maschinenlesbar:
|
|
|
|
```bash
|
|
docker compose exec php php bin/console module:sync --format=json
|
|
```
|
|
|
|
### db:migrate
|
|
|
|
Wendet idempotente Core-Schema-Updates aus `db/updates/*.sql` an. Angewendete Files werden in der Tabelle `core_migrations` getrackt; jeder Lauf wendet nur neu hinzugekommene Files an.
|
|
|
|
Jede `db/updates/*.sql` MUSS idempotent sein (`CREATE TABLE IF NOT EXISTS`, `INSERT … ON DUPLICATE KEY UPDATE`, etc.) — Erstlauf gegen ein bereits bestehendes Schema ist damit ein No-op.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console db:migrate
|
|
```
|
|
|
|
`module:sync` ruft den Befehl als ersten Schritt automatisch auf. Direktaufruf nuetzlich, wenn nur DB-Updates gewuenscht sind ohne Module-Build.
|
|
|
|
Status-Anzeige (kein Schreibzugriff):
|
|
|
|
```bash
|
|
docker compose exec php php bin/console db:migrate --status
|
|
```
|
|
|
|
Listet `applied:` und `pending:` separat — nuetzlich beim Debugging veralteter Schemata.
|
|
|
|
### module:migrate
|
|
|
|
Wendet ausstehende SQL-Migrationen aus aktiven Modulen an.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console module:migrate
|
|
```
|
|
|
|
### module:permissions-sync
|
|
|
|
Synchronisiert Modul-Permissions in die DB. Deaktiviert verwaiste System-Permissions (`is_system=1`), die kein aktives Modul mehr beansprucht.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console module:permissions-sync
|
|
```
|
|
|
|
### module:build
|
|
|
|
Baut die Runtime-Seitenstruktur (`storage/runtime/pages/`) mit Symlinks zu Modul-Pages.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console module:build
|
|
```
|
|
|
|
### module:assets-sync
|
|
|
|
Publiziert Modul-Assets nach `web/modules/<id>/`.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console module:assets-sync
|
|
```
|
|
|
|
### module:deactivate
|
|
|
|
Fuehrt den optionalen Deactivation-Handler eines Moduls aus.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console module:deactivate <module-id> --confirm
|
|
docker compose exec php php bin/console module:deactivate <module-id> --dry-run
|
|
```
|
|
|
|
Das Modul muss nicht in der Aktivliste stehen. `--dry-run` validiert den Handler ohne Ausfuehrung.
|
|
|
|
### scheduler:run
|
|
|
|
Fuehrt faellige Scheduler-Jobs aus.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console scheduler:run
|
|
```
|
|
|
|
Der Docker-Scheduler-Service ruft dieses Kommando automatisch alle 60 Sekunden auf.
|
|
|
|
### module:validate
|
|
|
|
Validiert Manifest, Klassen und Struktur eines Moduls. Prueft JSON-Schema-Compliance des `module.php`, Namespace-Konventionen, Interface-Implementierungen, Permission-Key-Formate und Verzeichnisstruktur.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console module:validate <module-id>
|
|
docker compose exec php php bin/console module:validate --all
|
|
```
|
|
|
|
`--all` validiert alle Module auf Disk (`modules/*/module.php`) auf einmal.
|
|
|
|
### make:module
|
|
|
|
Erzeugt die vollstaendige Verzeichnisstruktur fuer ein neues Modul inkl. Manifest, ContainerRegistrar-Stub, AuthorizationPolicy-Stub und leeren Verzeichnissen.
|
|
|
|
```bash
|
|
docker compose exec php php bin/console make:module <module-id>
|
|
```
|
|
|
|
Argument `module-id` muss dem Pattern `[a-z][a-z0-9-]*` entsprechen.
|
|
|
|
### doctor
|
|
|
|
Fuehrt System-Gesundheitschecks aus (ENV, DB, RBAC, Scheduler-Heartbeat).
|
|
|
|
```bash
|
|
docker compose exec php php bin/console doctor
|
|
```
|
|
|
|
Siehe `/docs/howto-betriebscheck-doctor.md` fuer Details.
|
|
|
|
Maschinenlesbar:
|
|
|
|
```bash
|
|
docker compose exec php php bin/console doctor --format=json
|
|
```
|
|
|
|
## Developer-Orchestrator (`bin/dev`)
|
|
|
|
Fuer lokalen Workflow gibt es zusaetzlich den Dev-Orchestrator:
|
|
|
|
```bash
|
|
bin/dev init
|
|
bin/dev up
|
|
bin/dev down
|
|
bin/dev logs [service]
|
|
bin/dev console module:sync
|
|
bin/dev qa
|
|
bin/dev qa-required
|
|
bin/dev qa-extended
|
|
```
|
|
|
|
`bin/dev console ...` delegiert intern auf `docker compose exec -T php php bin/console ...`.
|
|
`bin/dev qa` ist ein Alias fuer `bin/dev qa-required`.
|
|
|
|
## Neue Kommandos anlegen
|
|
|
|
1. Klasse in `core/Console/Commands/` erstellen, die `MintyPHP\Console\Command` erweitert.
|
|
2. `name()`, `description()` und `execute()` implementieren.
|
|
3. Optional: `usage()` fuer `--help`-Ausgabe ueberschreiben.
|
|
|
|
Das Kommando wird automatisch erkannt — kein manuelles Registrieren noetig.
|
|
|
|
Beispiel:
|
|
|
|
```php
|
|
namespace MintyPHP\Console\Commands\Make;
|
|
|
|
use MintyPHP\Console\Command;
|
|
|
|
final class ModuleCommand extends Command
|
|
{
|
|
public function name(): string { return 'make:module'; }
|
|
public function description(): string { return 'Scaffold a new module'; }
|
|
|
|
public function execute(array $args, array $options): int
|
|
{
|
|
// ...
|
|
return 0;
|
|
}
|
|
}
|
|
```
|
|
|
|
## Bootstrap-Helfer
|
|
|
|
Die `Command`-Basisklasse stellt Helfer bereit:
|
|
|
|
| Methode | Zweck |
|
|
|---|---|
|
|
| `$this->bootstrapApp($channel)` | App-Bootstrap fuer Nicht-Modul-Kommandos |
|
|
| `$this->projectRoot()` | Gibt den absoluten Projekt-Root-Pfad zurueck |
|