一键导入
integrate
Integrate llbbl/enum-state-machine into a PHP project with enum states, attribute transitions, guards, hooks, and validation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Integrate llbbl/enum-state-machine into a PHP project with enum states, attribute transitions, guards, hooks, and validation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Use dfm to initialize dotfile backups, track files safely, sync private repositories, and review AI-suggested dotfile improvements
Work on llbbl/esm, a PHP enum-state-machine library, with its local quality gates and API constraints
Use grepwrite gw to find matches, preview code rewrites, apply transactional edits with snapshots, and undo safely
Integrate logan-logger into TypeScript apps with correct runtime imports, environment config, safe metadata, and validation
Use pkglock to switch package-lock.json between local npm registries and the public registry, and install safeguards against committing local URLs
Use repjan to audit GitHub repositories, review archive candidates, export decisions, and safely archive or unarchive repos
| name | integrate |
| version | 0.1.0 |
| description | Integrate llbbl/enum-state-machine into a PHP project with enum states, attribute transitions, guards, hooks, and validation |
| allowed-tools | Bash, Read, Grep, Glob, Edit, MultiEdit, Write |
Use this skill when the user wants to add or improve llbbl/enum-state-machine in a PHP project, such as:
composer.json, PHP version constraints, framework clues, and the existing domain model.>=8.1.composer require llbbl/enum-state-machine
Use the project’s existing dependency workflow if it wraps Composer.
Prefer one focused enum per workflow:
use EnumStateMachine\Attributes\Transition;
enum OrderState: string
{
#[Transition(to: self::Processing)]
case Paid = 'paid';
#[Transition(to: self::Shipped, guard: HasValidAddress::class)]
case Processing = 'processing';
case Shipped = 'shipped';
case Cancelled = 'cancelled';
}
Use class-level transitions for wildcard behavior:
use EnumStateMachine\Attributes\Transition;
#[Transition(to: self::Cancelled)]
enum OrderState: string
{
case Pending = 'pending';
case Paid = 'paid';
case Cancelled = 'cancelled';
}
Use StateMachine at the boundary where state changes happen:
use EnumStateMachine\StateMachine;
$machine = new StateMachine($order->state);
if (! $machine->can(OrderState::Shipped, context: $order)) {
// Reject or hide the transition.
}
$order->state = $machine->transitionTo(OrderState::Shipped, context: $order);
Use guards for validation that decides whether a transition is allowed. Guards must be side-effect-free because can() runs them:
use EnumStateMachine\Contracts\GuardInterface;
final class HasValidAddress implements GuardInterface
{
public function __invoke(object $from, object $to, mixed $context = null): bool
{
return $context?->shippingAddress !== null;
}
}
Use hooks for side effects:
before hooks run before the state changes.after hooks run after the state changes.StateMachine from an application service, action, command handler, or controller boundary.StateMachine.#[StateMachineConfig(dispatchEvents: true)] and provide a dispatcher.When replacing string statuses:
transitionTo().Run the target project’s existing checks. Common PHP commands:
composer test
composer qa
vendor/bin/pest
vendor/bin/phpunit
vendor/bin/phpstan analyse
If no test command exists, add focused tests around the state enum and the state-changing service before changing production call sites.