Developers

Console Commands

Vizy includes console commands you can run from your Craft project’s directory.

Options can be written in kebab case, such as --dry-run, or camel case, such as --dryRun. Commands that print JSON put it after a short human-readable summary, so you can pipe the output into scripts.

Matrix Anchors

vizy/anchors/backfill

Gives Matrix content inside Vizy blocks its own owner where older content still relies on the Matrix data stored in the document. Run it after an upgrade, or when Content Recovery reports shared Matrix references. The command checks every element type on every site, resaves only the element and site rows that need a backfill, and preserves their last-updated dates. Its counts refer to element and site rows, so a multisite element can appear more than once.

OptionDescriptionDefault
--dry-runLists the rows that would be saved without saving them.false
--element-idOnly checks the element with this ID.All elements
--siteOnly checks this site handle.All sites
--draftsIncludes drafts and provisional drafts.false
--revisionsIncludes revisions.false
--trashedIncludes trashed elements.false
--limitStops after checking this many element and site rows.No limit
--batch-sizeHow many elements to load from the database at a time.100
php craft vizy/anchors/backfill --dry-run
php craft vizy/anchors/backfill --site=default --element-id=123
php craft vizy/anchors/backfill --drafts --revisions --trashed

Matrix in Vizy Blocks explains when a backfill is needed and how to check the result.

Content Repair

vizy/content/fix-vizy-block-field-uids

Repairs block content saved in the Vizy 3 block format whose field values are keyed by a field UID instead of a field handle. For each value Vizy can't match to a field in the Block Type's layout, the command shows a preview of the content and asks you to choose the field it belongs to, then remembers that choice for the same UID. Run it interactively, and back up your database first, because it writes directly to the content table.

php craft vizy/content/fix-vizy-block-field-uids

Rich Text Conversion

These commands are the console equivalents of the guided migrations in Settings → Vizy → Migrations. Migrating Rich Text Fields walks through the complete process, including how to review the plans they print.

vizy/convert/analyze

Analyses a CKEditor or Redactor field before converting it to Vizy, and prints the JSON plan. It doesn't change Project Config or content. The command exits with an error code when the plan's status is blocked.

ArgumentDescriptionDefault
fieldThe handle of the CKEditor or Redactor field.Required
editorConfigThe ID of the Vizy Editor Config the converted field will use.standard
samplesThe maximum number of diagnostic samples to include.25
php craft vizy/convert/analyze articleBody
php craft vizy/convert/analyze articleBody article 50

vizy/convert/field

Converts a CKEditor or Redactor field to Vizy. It changes the field type through Project Config, writes a content migration to your project's content migration folder, applies it locally and verifies the result. It takes the same arguments as vizy/convert/analyze.

OptionDescriptionDefault
--allow-lossyConverts a field whose plan is requires-review, accepting the listed representation loss.false
php craft vizy/convert/field articleBody
php craft vizy/convert/field articleBody --allow-lossy

vizy/convert/analyze-from-vizy

Analyses copying a Vizy field into an existing Plain Text, CKEditor or Redactor field, and prints the JSON plan without changing anything. The command exits with an error code when the plan's status is blocked.

ArgumentDescriptionDefault
sourceThe handle or UID of the Vizy field.Required
destinationThe handle or UID of the existing destination field.Required
samplesThe maximum number of diagnostic samples to include.25
php craft vizy/convert/analyze-from-vizy articleBody articleBodyCkeditor

vizy/convert/from-vizy

Copies a Vizy field's content into an existing Plain Text, CKEditor or Redactor field and writes a content migration for the copy. The Vizy field and both field definitions stay unchanged. It takes the same arguments as vizy/convert/analyze-from-vizy.

OptionDescriptionDefault
--allow-lossyCopies content the destination field can't fully represent, accepting the listed changes.false
php craft vizy/convert/from-vizy articleBody articleBodyCkeditor --allow-lossy

Content Recovery

Content Recovery explains what recovery records contain and how to check a restored field.

vizy/recovery/index

Lists Vizy's recovery records as JSON, newest first, for every owner or for one owner element ID.

php craft vizy/recovery/index
php craft vizy/recovery/index 123

vizy/recovery/restore

Restores one recovery record by its ID. It replaces that Vizy field and its nested content across the record's sites, leaving the owner's other fields unchanged, and captures the content it replaces as a new record.

php craft vizy/recovery/restore 456

vizy/recovery/prune

Deletes older records captured automatically when an owner is saved, keeping the newest ones for each owner and Vizy field. Records captured before operations such as upgrades, conversions and ownership repairs are always kept.

ArgumentDescriptionDefault
keepHow many automatic records to keep for each owner and field.10
ownerIdOnly prunes the records for this owner element ID.All owners
php craft vizy/recovery/prune
php craft vizy/recovery/prune 5 123

Vizy 3 Upgrade

Craft's plugin migration upgrades Vizy 3 fields automatically. These commands expose the same upgrade for diagnosis, custom deployments and recovery work. The upgrade guide explains when to use them and the format of plan and owner-scope files.

Commands that write ask for confirmation and default to no. In a non-interactive deployment you must pass --force, so only do that after reviewing the plan.

vizy/migrations/upgrade-from-v3

Checks the installation for Vizy 3 fields and upgrades them. When an earlier upgrade didn't finish, the command resumes it instead. It stops with an error when the analysis isn't ready or when more than one unfinished upgrade exists.

OptionDescriptionDefault
--dry-runPrints the analysis, or the unfinished upgrade it would resume, without writing anything.false
--forceWrites without asking for confirmation.false
php craft vizy/migrations/upgrade-from-v3 --dry-run
php craft vizy/migrations/upgrade-from-v3 --force

vizy/migrations/upgrade-analyze

Analyses every Vizy 3 field in the current Project Config and prints the upgrade plan without writing anything. By default each Vizy 3 block type keeps its handle as a shared Block Type. When a handle isn't valid, or you want a different one, pass a JSON file as the optional argument that maps {fieldUid}:{blockTypeId} keys to the Block Type handles to use instead.

php craft vizy/migrations/upgrade-analyze
php craft vizy/migrations/upgrade-analyze path/to/handles.json

vizy/migrations/upgrade-dry-run

Checks a saved upgrade plan, and an optional owner-scope file, without writing anything. Both arguments are paths to JSON files and accept Craft aliases.

php craft vizy/migrations/upgrade-dry-run path/to/plan.json path/to/owners.json

vizy/migrations/upgrade-apply

Applies a saved upgrade plan and owner-scope file. It writes Project Config and converts the owner content the scope file lists.

OptionDescriptionDefault
--forceWrites without asking for confirmation.false
php craft vizy/migrations/upgrade-apply path/to/plan.json path/to/owners.json

vizy/migrations/upgrade-status

Lists upgrade runs with their status, stage, last error and next step. Pass a run UID to show one run.

php craft vizy/migrations/upgrade-status

vizy/migrations/upgrade-resume

Resumes an unfinished upgrade run from its last completed stage.

OptionDescriptionDefault
--forceWrites without asking for confirmation.false
php craft vizy/migrations/upgrade-resume a1b2c3d4-e5f6-7890-abcd-ef1234567890

Owner Migration

These low-level commands convert the content of one Vizy field on one owner, using a mapping file. Converting a Single Owner describes the mapping format.

vizy/migrations/owner

Analyses converting one owner's Vizy field, and applies it when you pass --apply=1. The arguments are the owner's element type class, element ID and site ID, the Vizy field's UID and the path to the mapping file.

OptionDescriptionDefault
--applyWrites the converted content. Without it, the command only analyses.false
--forceWrites without asking for confirmation.false
--owner-placement-uidThe field layout element UID, for a field placed more than once in the owner's layout.None
--run-uidRecords the conversion against this run UID.None
php craft vizy/migrations/owner "craft\elements\Entry" 123 1 a1b2c3d4-e5f6-7890-abcd-ef1234567890 path/to/mapping.json
php craft vizy/migrations/owner "craft\elements\Entry" 123 1 a1b2c3d4-e5f6-7890-abcd-ef1234567890 path/to/mapping.json --apply=1

vizy/migrations/status

Lists owner migration checkpoints with their next step. Pass a run UID to show the checkpoints for one run.

php craft vizy/migrations/status

vizy/migrations/resume

Resumes an owner migration from a checkpoint ID listed by vizy/migrations/status.

OptionDescriptionDefault
--forceWrites without asking for confirmation.false
php craft vizy/migrations/resume 42