Skip to content
docsv0.8.0

PluginMetadata

Declares plugin identity and dependency metadata (version, author, site, name, type, provides/requires/suggests service lists). Applied to a plugin's main class. A plugin's identity is immutable: all properties are `readonly`, so a reflection-obtained instance cannot be silently mutated after construction.

PluginMetadata::__construct()

public function __construct(string $version, string $author, string $site, string $name, string $type, array $provides = [], array $requires = [], array $suggests = [], array $aliases = []):

Parameters

Parameters of __construct()
NameTypeDescription
$versionstring
$authorstring
$sitestring
$namestring
$typestringThe plugin's kind, by what surface it exposes. `$type` is a plain `string`, not a backed enum — deliberately: the four values below are the observed, sanctioned vocabulary (every plugin across the Milpa ecosystem uses one of them, and the scaffolding CLI only ever generates one of them), but making it a native enum type would be a breaking change for every existing `#[PluginMetadata(type: '...')]` call site the moment a host application updates core, for a check this docblock (plus a lint/CI rule, if a host wants one) already covers. - `'Web'` — exposes HTTP-facing surface (controllers/routes). - `'CLI'` — exposes only CLI commands, no HTTP surface. - `'Service'` — exposes only services/tools consumed by other plugins or the runtime, no direct HTTP or CLI surface of its own. - `'Mixed'` — exposes more than one of the above (e.g. both HTTP routes and CLI commands).
$providesarray<(class-string | array<string, mixed>)>Capabilities this plugin provides. Each entry is either a bare interface FQCN (legacy, synthesized as an unversioned record) or a structured capability record `{id, interface, contractVersion, service, priority?, exclusive?}` (canonical — capability-spec §3.1, validated by {@see \Milpa\ValueObjects\Capability\CapabilityProvision}). Mixing both shapes in one list is valid — the incremental migration path.
$requiresarray<(class-string | array<string, mixed>)>Required capabilities (hard dependency): a bare interface FQCN or a record `{id, interface, constraint, oneOf?}` ({@see \Milpa\ValueObjects\Capability\CapabilityRequirement}).
$suggestsarray<(class-string | array<string, mixed>)>Optional capabilities (soft dependency): a bare interface FQCN or a record `{id, interface, constraint, fallback?}` ({@see \Milpa\ValueObjects\Capability\CapabilitySuggestion}).
$aliaseslist<string>The words a human would use for this plugin, so the app can resolve a reference instead of asking a model to guess one. They REFER; they do not operate — every operation keeps taking the real name and only the real name.