Workflows
A workflow gives the records of a resource a life cycle: states, transitions between them, who may run each transition, tasks and deadlines. The same rules apply in the panel, through the API and on the command line.
draft ──submit──▶ submitted ──approve──▶ approved (locked) ──order──▶ ordered ▲ │ └──submit── rejected ◀──reject──┘Concepts
Section titled “Concepts”| Concept | Meaning | Details |
|---|---|---|
| State | where a record is; one per workflow, stored in a column of the record | States |
| Transition | a step from one state to another, e.g. approve | Transitions |
| Actor | who may run a transition or complete a task | Actors |
| Task | work for people: a decision, or one of several approvals in parallel | Tasks in parallel, Tasks and inbox |
| Duration, deadline, forecast | how long each step may take, when the case must be finished, when it will probably be finished | Durations and deadline |
| Building block | guards, effects, forms and resolvers of the application, by key | Building blocks |
| Tenant configuration | per tenant: active or not, who decides, days, optional steps | Tenant configuration |
Principles
Section titled “Principles”- One state per workflow. Work in parallel (two approvals at once) is modelled with tasks, not with several states.
- Only transitions change the state. The state column is not part of the form; locked states protect the record from edits.
- Who decides is data. Actors are permissions, roles, the creator, a person in a field, a resolver of the application, or a slot each tenant configures – optionally released by a second administrator.
- Definitions are data. They are written in PHP, but the engine runs the data they produce; code is referenced by key. Every version is stored, and running records keep the version they started with.
- Everything is audited. Every transition, override, completed task and configuration change is in the audit log; the detail page shows the history.
Getting started
Section titled “Getting started”- Write the workflow class and attach it to the resource: Getting started.
- Add the state column to the table.
- Run
php spark anvil:workflow:check. - Register
Access::pages()in the panel (inbox and workflow settings). - Make the workflow available to tenants and let them activate it, or
mark it
required(). - Schedule
php spark anvil:tickevery minute (overdue steps, forecasts, reminders).
Not available
Section titled “Not available”There is no owner actor, no conditional form and no graphical designer; decision tables, change requests and recertification campaigns are not part of Anvil.