Download the PHP package dimita/laravel-business-orchestration-engine without Composer
On this page you can find all versions of the php package dimita/laravel-business-orchestration-engine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dimita/laravel-business-orchestration-engine
More information about dimita/laravel-business-orchestration-engine
Files in dimita/laravel-business-orchestration-engine
Package laravel-business-orchestration-engine
Short Description A Laravel library for business orchestration including Saga Pattern, Workflow, Event Sourcing, Versioning, Rule Engine, and more.
License MIT
Informations about the package laravel-business-orchestration-engine
Laravel Business Orchestration Engine
A comprehensive Laravel package for business orchestration, including Saga Pattern, Workflow Management, Event Sourcing, Versioning, Rule Engine, and Dependency Management.
Note: This package is based on battle-tested code patterns I've been using in production for years. I've packaged it to make these proven patterns easily reusable across projects.
[]()
[
]()
[
]()
[
]()
Requirements
- PHP: ^8.1 or higher
- Laravel: ^10.0 or ^11.0
- Database: MySQL 5.7+, PostgreSQL 10+, or SQLite 3.8+
- Extensions:
ext-json- JSON support for payload serializationext-pdo- Database connectivity
Optional Requirements
For enhanced saga orchestration capabilities:
- Queue Driver: Redis, Database, or SQS for asynchronous step execution
- Cache Driver: Redis or Memcached for performance optimization
- Message Queue (optional): RabbitMQ for distributed saga coordination
Table of Contents
- Installation
- Features
- Independent vs Combined Usage
- Usage Guide
- 1. Saga Pattern
- 2. Workflow Engine
- 3. Event Sourcing
- 4. Versioning
- 5. Rule Engine
- 6. Sync Engine
- 7. Dependency Engine
- Real-World Use Cases
- Architecture
- Testing
Installation
Install the package via Composer:
Publish the configuration and migrations:
Features
✨ 7 Powerful Engines
| Engine | Description | Use Case |
|---|---|---|
| Saga Pattern | Distributed transactions with automatic compensation | Complex business processes (orders, payments) |
| Workflow Engine | State machine with guards and transitions | Document validation, approval processes |
| Event Sourcing | Append-only event store | Audit trail, historical state reconstruction |
| Versioning | Immutable model snapshots | Change history, rollback capability |
| Rule Engine | Business rule evaluation via AST | Dynamic discounts, business validation |
| Sync Engine | Multi-device synchronization | Offline-first apps, mobile sync |
| Dependency Engine | Business constraint management | Pre-delete validation, dependency graphs |
Independent vs Combined Usage
This package offers maximum flexibility - use engines independently or together based on your needs.
Independent Usage
Perfect when you only need specific functionality:
Combined Usage
Use the main facade when working with multiple engines:
Available Aliases
When to Use Each Approach
| Approach | Best For |
|---|---|
| Independent (Class) | Type safety, IDE autocompletion, single-engine projects |
| Independent (Alias) | Quick prototyping, flexibility, simpler syntax |
| Dependency Injection | Production code, testability, SOLID principles |
| Combined Facade | Complex workflows using multiple engines |
Configuration for Selective Loading
Improve performance by loading only the engines you need. Edit config/business-orchestration.php:
Or use environment variables in your .env:
Benefits of selective loading:
- Reduced memory footprint
- Faster application bootstrap
- Cleaner service container
- Only load what you actually use
Note: If you try to use a disabled engine, you'll get a clear error message:
Usage Guide
1. Saga Pattern
When to use? When you have a business transaction involving multiple services and need to rollback (compensate) on failure.
Simple Example - Order Processing
Advanced Compensation
Define compensation logic for each step to properly rollback changes:
Asynchronous Execution
Execute sagas asynchronously using Laravel queues:
Resume After Crash
Cancel Running Saga
Saga Status Flow
PENDING- Saga created, not started yetRUNNING- Saga currently executingCOMPLETED- All steps completed successfullyFAILED- A step failed (before compensation)COMPENSATED- Completed steps have been rolled back after failureCANCELLED- Saga was manually cancelledCOMPENSATION_FAILED- Compensation encountered an error (step-level)
2. Workflow Engine
When to use? When you need a state machine to manage transitions between different business states.
Simple Example - Contract Validation
With Guards (Conditions)
Complex Workflow - Ticket Management
Advanced Features
Register Workflow Definition
Event Hooks
Get Available Transitions
Check Workflow State
Force State Change
3. Event Sourcing
When to use? When you need to keep a complete history of all changes and be able to rebuild state at any point in time.
Simple Example - Shopping Cart
Retrieve All Events
Advanced Features
Projectors - Create Read Models
Projectors listen to events and create read models (projections) for querying:
Reactors - Handle Side Effects
Reactors respond to events with side effects (emails, notifications, etc.):
Event Replay
Rebuild projections by replaying all events:
Snapshots for Performance
Create snapshots to avoid replaying thousands of events:
Metadata and Event Queries
4. Versioning
When to use? When you need to keep snapshots of your models to rollback or view history.
Simple Example - Document Versioning
Use Case - Contract Audit Trail
Advanced Versioning Features
Version Diffing
Compare differences between two versions:
Field Exclusion
Exclude sensitive or unnecessary fields from versioning:
Include Hidden Fields
Include normally hidden fields in version snapshots:
Revert to Previous Version
Quick revert to N versions back:
Version Metadata
Store contextual information with versions:
Version Utilities
5. Rule Engine
When to use? When you have business rules that change frequently and you want to manage them without modifying code.
Simple Example - Discount Rules
Rules with Custom Actions
Supported Operators
Advanced Rule Engine Features
Fluent Rule Builder
Create rules using a fluent, readable syntax:
Extended Operator Support
Logical Operations
Combine multiple conditions with AND/OR/NOT:
Rule Macros
Define reusable rule patterns:
Custom Operators
Register your own operators:
Rule Groups
Organize and evaluate rules in groups:
Priority-Based Evaluation
Rules with higher priority execute first:
Built-in Functions
Use built-in functions in rule conditions:
Get Matching Rules
Find all rules that pass for a context:
6. Sync Engine
When to use? To synchronize data between multiple devices (mobile app, web, etc.) with offline support.
Simple Example - Mobile Sync
Retrieving Changes (Mobile Client)
Offline Scenario
Advanced Sync Engine Features
Conflict Resolution
Handle conflicts when data changes on both client and server:
Conflict Strategies
Choose how conflicts are resolved:
Custom Conflict Handlers
Register custom handlers for specific fields:
Selective Field Sync
Sync only specific fields:
Batch Synchronization
Sync multiple model pairs at once:
Sync Checkpoints
Create named checkpoints for restore points:
Sync Status Monitoring
Track synchronization activity:
Model Comparison
Compare two models without syncing:
Apply Deltas
Apply a set of changes to a model:
Metadata Tracking
Track sync context and metadata:
Cleanup Old Logs
Purge old synchronization logs to save space:
7. Dependency Engine
When to use? To manage business dependencies and prevent deletions that would violate constraints.
Simple Example - Prevent Deletion
Complex Dependency Graph
Dependency Rule Types
Real-World Use Cases
E-commerce - Complete Order Process
SaaS - Subscription Management
Architecture
Package Structure
Design Principles
- Human-friendly logic: Clear and intuitive API
- Production-ready: Error handling, compensation, crash recovery
- Persistent: Everything saved to database
- Extensible: Multi-driver support (DB, Redis, Queue)
- Testable: 122 tests, 100% coverage
Architecture Diagrams
1. Saga Pattern Flow
2. Workflow State Machine
3. Event Sourcing Stream
4. Version Control System
5. Rule Engine AST Evaluation
6. Sync Engine Delta Synchronization
7. Dependency Graph System
Overall System Architecture
Testing
The package includes 122 tests covering all use cases:
Test Coverage by Engine
- SagaEngine: 16 tests (compensation, resume, states)
- WorkflowEngine: 16 tests (transitions, guards, states)
- RuleEngine: 18 tests (evaluation, AST, actions)
- DependencyEngine: 17 tests (graphs, constraints)
- EventSourcingEngine: 16 tests (events, rebuild, versioning)
- VersionEngine: 19 tests (snapshots, restore, audit)
- SyncEngine: 20 tests (deltas, offline, incremental)
Configuration
Publish the configuration file:
Available in config/business-orchestration.php:
Configuration Examples
Scenario 1: E-commerce application (needs Saga, Workflow, Versioning)
Scenario 2: Mobile-first app with offline support
Scenario 3: Enterprise workflow system
Support
- Documentation: This README
- Issues: GitHub Issues
- Tests: 100% coverage, 122 tests
License
MIT License - Free for commercial and open-source projects.
Changelog
v1.0.0 (2025)
- ✅ Saga Pattern with automatic compensation
- ✅ Workflow Engine with guards
- ✅ Event Sourcing with rebuild
- ✅ Versioning with snapshots
- ✅ Rule Engine with AST
- ✅ Sync Engine for multi-device
- ✅ Dependency Engine for business constraints
- ✅ 122 tests with 100% coverage
- ✅ Production-ready with complete error handling
Made with ❤️ for the Laravel community
Based on production-tested patterns I've refined over years of building enterprise applications.