Commands
Anvil’s commands are in the Anvil group of php spark list; the
generators start with make:anvil-. Operator commands (tenants, API
clients) write their changes to the audit log.
Setup and operation
Section titled “Setup and operation”| Command | Purpose |
|---|---|
anvil:install [--tenant <name>] [--username <name>] [--email <e-mail>] [--group <group>] [--promote <e-mail>] |
First setup: migrations, assets, first tenant (default “Default”), administrator and role “Administrator”, see Installation |
anvil:publish |
Copies the CSS, JavaScript and fonts to public/ (with integrity hashes), see Styling |
anvil:prune [--days 90] |
Deletes expired exports, notifications read more than --days ago, API access log entries older than $apiAccessLogDays and stored API answers older than a day, logouts announced by single sign-on providers after 30 days; schedule daily |
anvil:tick |
Periodic work: workflow deadlines, reminders of overdue tasks, modules via the event anvilTick; schedule every minute |
anvil:permissions |
Lists all permissions of the panels: resources (incl. export), actions, bulk actions, relation actions, pages, workflows, configuration |
Tenants
Section titled “Tenants”| Command | Purpose |
|---|---|
anvil:tenant:list, :create, :rename, :disable, :enable, :delete, :add-member, :remove-member |
Tenant administration, see Tenancy |
anvil:tenancy:enable --tenant <name>, anvil:tenancy:disable |
Switch multi tenancy on or off with existing data, see Without tenants |
Audit log
Section titled “Audit log”| Command | Purpose |
|---|---|
anvil:audit:verify [--batch 500] |
Checks the hash chain of the audit log; exit code 1 if it was tampered with |
anvil:rekey |
Completes a rotation of encryption.key: encrypts the TOTP secrets and API signing secrets with the current key, see Rotating encryption.key |
anvil:audit:rotate |
Completes a key rotation: records audit.key_rotated, signs the chain head with the new key, verifies the log |
anvil:audit:generate-key |
Prints a new audit key for anvil.auditKey, see Key rotation |
| Command | Purpose |
|---|---|
anvil:api:client:create, :list, :enable, :disable, :delete, :permissions |
API clients of a tenant, see API |
anvil:api:token:create, :list, :revoke |
Tokens of an API client |
anvil:api:review |
Notifies owners of expiring API tokens and clients and of unused clients; schedule daily |
anvil:api:openapi [--output <file>] |
Writes the OpenAPI 3.1 description of all API endpoints |
Workflows
Section titled “Workflows”| Command | Purpose |
|---|---|
anvil:workflow:list [--tenant <slug>] |
Workflows and versions; with --tenant availability and configuration in the tenant |
anvil:workflow:enable <key> --tenant <slug>, anvil:workflow:disable <key> --tenant <slug> |
Make a workflow available to a tenant, take it away |
anvil:workflow:check |
Validates the definitions and stores new versions; run on deployment |
anvil:workflow:migrate <key> --from <n> [--map a:b,…] [--dry-run] |
Moves records to the current version |
anvil:workflow:diagram <key> [--version <n>] |
Prints a Mermaid state diagram |
See Workflows.
Tables, models and resources
Section titled “Tables, models and resources”make:anvil-model
Section titled “make:anvil-model”Creates migration, model and entity of a table with everything Anvil needs:
uuid BINARY(16) with unique key, tenant_id with foreign key, timestamps,
keys and foreign keys of references.
php spark make:anvil-model Invoice \ --fields "number!:string:30,customer_id:belongs_to,amount:decimal:12.2,paid:bool,due_on:date,notes:text,tags:json" \ --soft-deletes --resource| Type | Column | Field in the generated resource |
|---|---|---|
string[:length] |
VARCHAR (255) | TextInput (email, phone, URL by name) |
text |
TEXT | Textarea |
int |
INT | NumberInput::integer() |
decimal[:12.2] |
DECIMAL | NumberInput, currency('EUR') for amounts by name (amount, price, total, …) |
bool |
TINYINT(1), default 0 | Toggle |
date, datetime |
DATE, DATETIME | DateInput |
json |
JSON | TagsInput for names with “tag”, otherwise a TODO for a Repeater |
belongs_to[:table] |
INT unsigned + foreign key (ON DELETE RESTRICT) | searchable BelongsTo |
! after the name makes the column NOT NULL and the field required.
Options: --table, --soft-deletes, --no-tenant (shared table),
--resource, --force. Then run php spark migrate.
make:anvil-resource
Section titled “make:anvil-resource”Creates resource, model and entity from an existing table (it must have
a uuid column). Fields and columns are derived as above; columns after the
fourth are toggleable. Options: --table, --force.
make:anvil-pivot
Section titled “make:anvil-pivot”Creates the pivot table and model of a many-to-many relation:
php spark make:anvil-pivot ProjectLabel --parent projects --related labelsOptions: --table, --no-tenant, --force. The command prints the
relation to add to the parent resource.
Extensions
Section titled “Extensions”These commands create a class and, where needed, its view below
app/Views. Options: --namespace, --suffix, --force.
| Command | Creates | View |
|---|---|---|
make:anvil-field Rating |
App\Fields\Rating extends Field |
app/Views/fields/rating.php |
make:anvil-column Progress |
App\Columns\Progress extends Column |
– |
make:anvil-filter Region |
App\Filters\Region extends Filter |
app/Views/filters/region.php |
make:anvil-layout Box |
App\Layouts\Box extends Component |
app/Views/layouts/box.php |
make:anvil-page Reports --suffix |
App\Pages\ReportsPage extends Page |
app/Views/pages/reports.php |
make:anvil-widget OpenDeals |
App\Widgets\OpenDeals implements Widget |
app/Views/widgets/open_deals.php |
make:anvil-policy Deal --suffix |
App\Policies\DealPolicy implements Policy |
– |
make:anvil-panel Partner --suffix |
App\Panels\PartnerPanel extends Panel |
– |
The generated code is a starting point with comments on what to adjust; see Extending Anvil for the rules every extension must follow (escaping, CSP, htmx).