Console commands
zoo/census/run
Takes a census and prints what each enclosure found, followed by the probe list.
php craft zoo/census/run
php craft zoo/census/run --audit=unused-assets
Taking a census…
unused-assets 312 of 4,109 scanned, 3,790 referenced, 7 excluded, 1.4 GB reclaimable
unrelated-entries 18 of 2,204 scanned, 2,186 referenced, 0 excluded
orphaned-nested-entries 0 of 8,812 scanned, 0 referenced, 0 excluded
unused-tags 44 of 391 scanned, 347 referenced, 0 excluded
Census #12: 374 unreferenced, 1.4 GB reclaimable, 6.1s.
How hard Zoo looked:
✓ Relational fields 8331 found
✓ Nested-entry ownership 612 found
✓ Reference tags in stored content 41 found
✓ URLs in stored markup 196 found
✓ Twig templates and config 7 found across 412 places
✓ Other tables keyed into elements 53 found across 158 places
zoo/census/report
Prints the last census without taking a new one. Cheap, and safe on production.
zoo/census/audits
Lists every audit and whether it is switched on.
zoo/census/clean
Deletes what the last census found. A dry run unless --force is given, and it says so on
every line.
php craft zoo/census/clean # what would happen
php craft zoo/census/clean --force # do it, to the trash
php craft zoo/census/clean --force --purge # do it, permanently
php craft zoo/census/clean --force --audit=unused-assets --limit=50
| Option | Default | |
|---|---|---|
--audit | every enabled audit | Only this one |
--force | off | Actually delete |
--purge | off | Permanently, rather than to the trash |
--limit | 100 | The most things to delete in one go |
clean refuses to run against a stale census. Take a fresh one first — the whole point is that the
list is current.
In a deploy script
The useful shape is report-only, and failing the build when the number grows:
php craft zoo/census/run --audit=orphaned-nested-entries
Orphaned nested entries and dangling relations should both be zero on a healthy site. A number appearing there means something deleted elements without going through Craft, which is worth knowing about long before anybody is deciding whether to delete them.
Do not put clean --force in a deploy. Zoo's guards assume a person read the evidence.