pixielity/laravel-workflow 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pixielity/laravel-workflow

Composer 安装命令:

composer require pixielity/laravel-workflow

包简介

Workflow engine for Laravel applications with state management and transitions

README 文档

README

This directory contains standard reference implementations and documentation for creating workflows and steps.

📚 Documentation

Start here to understand the patterns:

  1. WORKFLOW_PATTERNS.md - Quick reference guide with golden rules and checklists
  2. YIELD_PATTERN_EXPLAINED.md - Deep dive into yield vs yield from with visual diagrams
  3. Workflows/README.md - Comprehensive documentation with templates

🎯 Reference Implementation

Workflows/CreatePolicy/ - Complete working example demonstrating all patterns:

  • CreatePolicyWorkflow.php - Main workflow orchestration
  • Steps/ValidatePolicyDataStep.php - Validation step (no retries)
  • Steps/CreatePolicyStep.php - Database operation step (with retries)
  • Steps/NotifyPolicyCreatedStep.php - Notification step (with retries)

🚀 Quick Start

Creating a New Workflow

  1. Create workflow folder: Workflows/MyWorkflow/
  2. Create workflow class extending Workflow
  3. Create Steps/ subfolder for workflow-specific steps
  4. Follow the patterns in CreatePolicy/ example

Creating a New Step

  1. Extend Step base class
  2. Use typed parameters in execute() method
  3. Implement before() hook for validation
  4. Set $name, $enableLogging, $maxRetries properties
  5. Return structured data (array or DTO)

📖 Key Patterns

Yield Usage

// In main execute() - use `yield from` for helper methods
public function execute(): Generator
{
    yield from $this->validate();
    $data = yield from $this->create();
}

// In helper methods - use `yield` for steps
protected function validate(): Generator
{
    $result = yield $this->step(ValidateStep::class, $dto);
}

Argument Mapping

// Step with typed parameters
public function execute(MyDto $dto, MyService $service): array
{
    // Auto-mapped to $this->args->dto and $this->args->service
}

// Access in hooks
protected function before(): void
{
    /** @phpstan-ignore-next-line property.notFound */
    $dto = $this->args->dto;
}

Response Types

// Workflows return WorkflowResponse
return WorkflowResponse::success(['data' => $result]);

// Steps return structured data
return ['success' => true, 'data' => $result];

🎓 Learning Path

  1. Start: Read WORKFLOW_PATTERNS.md for quick overview
  2. Understand: Read YIELD_PATTERN_EXPLAINED.md to understand yield usage
  3. Study: Review Workflows/CreatePolicy/ reference implementation
  4. Reference: Use Workflows/README.md as detailed reference
  5. Build: Create your own workflow following the patterns

✅ Checklist

Before creating a workflow, ensure you understand:

  • [ ] When to use yield vs yield from
  • [ ] How arguments are auto-mapped to $this->args
  • [ ] How to return WorkflowResponse from workflows
  • [ ] How to use WorkflowStatus enum
  • [ ] How to implement before() hook in steps
  • [ ] How to set retry configuration per step
  • [ ] How to access step arguments via DataObject

🔍 Common Issues

IssueSolution
"Generator object instead of result"Use yield from for helper methods, not yield
"Step not executing"Use yield for steps, not yield from
"Can't access $this->args->property"Add @phpstan-ignore-next-line property.notFound
"Arguments not mapped"Ensure parameter names match what you access in $this->args

📁 Directory Structure

examples/
├── README.md                          # This file
├── WORKFLOW_PATTERNS.md               # Quick reference
├── YIELD_PATTERN_EXPLAINED.md         # Yield pattern deep dive
└── Workflows/
    ├── README.md                      # Detailed documentation
    └── CreatePolicy/                  # Reference implementation
        ├── CreatePolicyWorkflow.php
        └── Steps/
            ├── ValidatePolicyDataStep.php
            ├── CreatePolicyStep.php
            └── NotifyPolicyCreatedStep.php

🤝 Contributing

When adding new examples:

  1. Follow the established patterns
  2. Add comprehensive docblocks
  3. Include pattern notes in comments
  4. Update this README if adding new concepts
  5. Ensure code passes diagnostics

📞 Support

If you're unsure about a pattern:

  1. Check WORKFLOW_PATTERNS.md quick reference
  2. Review CreatePolicy/ example
  3. Read YIELD_PATTERN_EXPLAINED.md for yield questions
  4. Consult Workflows/README.md for detailed docs

pixielity/laravel-workflow 适用场景与选型建议

pixielity/laravel-workflow 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「workflow」 「laravel」 「state-machine」 「transitions」 「pixielity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 pixielity/laravel-workflow 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pixielity/laravel-workflow 我们能提供哪些服务?
定制开发 / 二次开发

基于 pixielity/laravel-workflow 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 29
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-09