The reservation book keeps growing. Reservations honored or canceled months ago pile up in it, and the reservation book page is slowing down. Gorm wants a big clean-up command, to run once a month (and one day, through a scheduled task).
A command that deletes data in bulk deserves some care: you want to be able to look before deleting, follow its progress, and be sure it copes with thousands of reservations.
Long-running tasks
--dry-run: by convention, a command offers a “dry run” mode, which shows what would be done without doing anything.- The progress bar:
$io->progressIterate()wraps a loop and displays the progress. - Batches: Doctrine keeps in memory every entity it loads. With
toIterable(), the entities arrive one by one; every N, you write (flush()) then empty the memory (clear()). - Verbosity:
-v,-vv,-vvvask for more details;$io->isVerbose()lets you give them only on request.
Your mission
Write app:registre:purger (purge the reservation book):
- it deletes the finished reservations (
honoredorcanceled) whose day is before the cutoff: by default, 30 days ago. The others stay put. Summary:2 reservations purged.; --dry-rundeletes nothing and announces2 reservations would be purged.;--avant(before) chooses the cutoff:--avant 2026-08-01, or a relative one like--avant "last month". An unreadable date givesCommand::INVALIDand “Invalid date”;- it processes the reservations in batches, with a progress bar, down to the very last one;
- with
-v, it lists each purged reservation: “Boromir, July 2, 2026 (honored)”.
In the Console tab: app:registre:purger --dry-run --avant today -v, then without --dry-run.