azaharizaman/nexus-workflow 问题修复 & 功能扩展

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

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

azaharizaman/nexus-workflow

Composer 安装命令:

composer require azaharizaman/nexus-workflow

包简介

Framework-agnostic workflow engine for Nexus ERP monorepo

README 文档

README

Framework-agnostic workflow engine for Nexus ERP monorepo

Overview

The Workflow package provides a powerful, flexible workflow engine that supports:

  • State Machine Management: Define and execute finite state machines with guards and hooks
  • Task Management: User task inbox with approval workflows
  • Conditional Routing: Dynamic routing based on workflow data
  • Parallel Execution: AND/OR gateways for complex approval flows
  • Multi-Approver Strategies: Unison, majority, quorum, weighted, first-wins
  • Escalation & SLA: Automatic escalations and SLA breach tracking
  • Delegation: User delegation with date ranges and chain limits
  • Compensation Logic: Rollback activities in reverse order on failure
  • Approval Matrix: Threshold-based routing configuration
  • Event-Driven Timers: Scalable timer system for scheduled actions
  • Plugin Architecture: Extensible activities, conditions, strategies, and triggers

Core Philosophy

This package is framework-agnostic. It defines WHAT workflows need to do (the logic), not HOW they are persisted or implemented. All database operations, Laravel-specific features, and Eloquent models belong in the apps/Atomy application layer.

Architecture

packages/Workflow/
├── src/
│   ├── Contracts/          # Interfaces defining all dependencies
│   ├── Core/               # Internal workflow engine (state machine, task engine, etc.)
│   ├── Services/           # Public API (WorkflowManager, TaskManager, etc.)
│   ├── ValueObjects/       # Immutable data structures
│   └── Exceptions/         # Domain-specific exceptions

Key Interfaces

Workflow & State Management

  • WorkflowInterface - Workflow instance representation
  • StateInterface - Workflow state representation
  • TransitionInterface - State transition representation
  • WorkflowRepositoryInterface - Persistence contract

Task Management

  • TaskInterface - User task representation
  • TaskRepositoryInterface - Task persistence contract
  • InboxInterface - Task inbox query interface

Execution & Control

  • StateEngineInterface - State transition execution
  • TaskEngineInterface - Task creation and completion
  • ConditionEvaluatorInterface - Condition expression evaluation
  • ApprovalStrategyInterface - Multi-approver logic

Automation

  • EscalationInterface - Escalation rule processing
  • SlaTrackerInterface - SLA monitoring and breach detection
  • TimerInterface - Timer management
  • DelegationInterface - User delegation handling

Extensibility

  • ActivityInterface - Plugin activities (email, webhook, etc.)
  • TriggerInterface - Workflow triggers (webhook, schedule, event)
  • StorageInterface - Custom storage backends

Value Objects

  • State - Workflow state definition
  • Transition - State transition definition
  • TaskAction - Task action (approve, reject, request changes)
  • SlaStatus - SLA tracking status (on_track, at_risk, breached)
  • ApprovalStrategy - Multi-approver strategy enum
  • EscalationRule - Escalation configuration
  • WorkflowData - Typed workflow data container
  • ConditionExpression - Parsed condition expression

Services (Public API)

WorkflowManager

Primary entry point for workflow operations:

  • instantiate(definition, data) - Create new workflow instance
  • apply(workflow, transition) - Execute state transition
  • can(workflow, transition) - Check if transition is allowed
  • history(workflow) - Retrieve state change history

TaskManager

Task operations:

  • createTask(workflow, state, assignee) - Create user task
  • completeTask(task, action, comment) - Complete task with action
  • delegate(user, delegatee, dateRange) - Delegate tasks

InboxService

Task inbox queries:

  • forUser(userId) - Get tasks for specific user
  • pending() - Filter pending tasks
  • filter(criteria) - Apply filters (workflow type, priority, due date)

EscalationService

Escalation management:

  • processEscalations() - Process overdue tasks
  • defineRule(state, threshold, action) - Configure escalation rules

SlaService

SLA tracking:

  • trackSla(workflow) - Monitor SLA status
  • getSlaStatus(workflow) - Get current SLA status
  • getBreaches() - Retrieve breached workflows

DelegationService

Delegation management:

  • createDelegation(delegator, delegatee, dateRange) - Create delegation
  • revokeDelegation(delegation) - Cancel delegation
  • getDelegationChain(user) - Get delegation chain

Exceptions

  • WorkflowNotFoundException - Workflow not found
  • InvalidTransitionException - Transition not allowed from current state
  • TaskNotFoundException - Task not found
  • UnauthorizedTaskActionException - User not authorized to act on task
  • InvalidWorkflowDefinitionException - Invalid workflow structure
  • GuardConditionFailedException - Transition guard condition failed
  • SlaBreachException - SLA deadline breached
  • DelegationChainExceededException - Delegation chain too deep (>3 levels)
  • CircularDependencyException - Circular state dependency detected
  • InvalidConditionExpressionException - Invalid condition syntax

Usage Example (Conceptual)

use Nexus\\Workflow\\Services\\WorkflowManager;

// Inject via constructor
public function __construct(
    private readonly WorkflowManager $workflowManager
) {}

// Check if transition is allowed
if ($this->workflowManager->can($workflow, 'approve')) {
    // Execute transition
    $this->workflowManager->apply($workflow, 'approve');
}

// Get history
$history = $this->workflowManager->history($workflow);

Implementation

The consuming application (apps/Atomy) must provide:

  1. Eloquent Models implementing workflow interfaces
  2. Repository Classes implementing repository interfaces
  3. Database Migrations for all workflow tables
  4. Service Provider binding interfaces to implementations
  5. HasWorkflow Trait for Eloquent models
  6. API Routes exposing workflow functionality

See apps/Atomy/app/ for concrete implementations.

Requirements Coverage

This package fulfills requirements:

  • ARC-WOR-0405 to ARC-WOR-0414 (Architectural requirements)
  • BUS-WOR-0415 to BUS-WOR-0424 (Business requirements)
  • FUN-WOR-0425 to FUN-WOR-0541 (Functional requirements)
  • PERF-WOR-0543 to PERF-WOR-0547 (Performance requirements)
  • SEC-WOR-0548 to SEC-WOR-0553 (Security requirements)
  • REL-WOR-0554 to REL-WOR-0558 (Reliability requirements)
  • SCL-WOR-0559 to SCL-WOR-0562 (Scalability requirements)
  • MAINT-WOR-0563 to MAINT-WOR-0566 (Maintainability requirements)
  • USE-WOR-0567 to USE-WOR-0584 (User stories)

📖 Documentation

Package Documentation

Additional Resources

  • IMPLEMENTATION_SUMMARY.md - Implementation progress
  • REQUIREMENTS.md - Requirements
  • TEST_SUITE_SUMMARY.md - Tests
  • VALUATION_MATRIX.md - Valuation

License

MIT License - see LICENSE file for details

azaharizaman/nexus-workflow 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-04