Skip to content

Definitions Overview

Workflows are defined using one of two formats:

FormatBest For
PHP AttributesTeams who prefer PHP-first, IDE refactoring support
NEON/YAMLOps teams, file-based changes, declarative config

Both formats resolve to the same runtime model.

Quick Comparison

php
#[InitialState]
#[Transition(to: PaidState::class, name: 'pay', happy: true)]
class PendingState extends BaseOrderState
{
    #[Guard('pay')]
    public function ensurePayable(): bool|string
    {
        return $this->getEntity()->total > 0
            ? true
            : 'Order total must be positive';
    }
}
neon
order:
  table: Orders
  field: state
  states:
    pending:
      initial: true
    paid:
      color: '#00AA00'
  transitions:
    pay:
      from: [pending]
      to: paid
      happy: true

Choosing a Format

PHP Attributes

Use when:

  • Your team prefers PHP-first definitions
  • Guards and commands live naturally in state classes
  • You want IDE navigation and refactoring
  • Logic and state definition are tightly coupled

NEON or YAML

Use when:

  • Operations teams need easy file-based changes
  • Definitions should be declarative data
  • You want to review graph changes without touching PHP
  • Guards/commands are minimal or external

Format Details

Core Concepts

For understanding states, transitions, guards, and commands, see Concepts.

Released under the MIT License.