adamczykpiotr / laravel-dag-workflows
This is my package dag-workflows
Fund package maintenance!
AdamczykPiotr
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/adamczykpiotr/laravel-dag-workflows
Requires
- php: ^8.3
- illuminate/contracts: ^11.0||^12.0
- laravel/serializable-closure: ^2.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
This package is auto-updated.
Last update: 2025-11-16 17:24:36 UTC
README
A lightweight library to define and dispatch directed acyclic graph (DAG) based workflows composed of Tasks and TaskGroups. Each Task can contain one or more jobs and may declare dependencies on other tasks. This package helps model, persist and execute complex multi-step workflows in Laravel applications.
Key features:
- Expressive workflow definitions using
Workflow,TaskandTaskGroupbuilding blocks - Support for single and grouped tasks
- Task dependencies and ordering
- Easy dispatching and inspection via Eloquent models
Installation
Install the package via Composer and run migrations:
composer require adamczykpiotr/laravel-dag-workflows
php artisan vendor:publish --tag="dag-workflows-migrations"
php artisan migrate
Usage
Below is a concise example showing how to define and dispatch a workflow. This example mirrors the structure of the included tinker snippet but models an "Image Import Pipeline":
<?php use AdamczykPiotr\DagWorkflows\Definitions\Task; use AdamczykPiotr\DagWorkflows\Definitions\TaskGroup; use AdamczykPiotr\DagWorkflows\Definitions\Workflow; const TASK_FETCH_FEEDS = 'fetch_feeds'; const TASK_PARSE_CATALOGS = 'parse_catalogs'; const TASK_PARSE_ALBUMS = 'parse_albums'; const TASK_PARSE_IMAGES = 'parse_images'; const TASK_PARSE_METADATA = 'parse_metadata'; const TASK_SYNC_CATALOG_ALBUM_RELATIONS = 'sync_catalog_album_relations'; const TASK_SYNC_ALBUM_IMAGE_RELATIONS = 'sync_album_image_relations'; const TASK_SYNC_IMAGE_METADATA_RELATIONS = 'sync_image_metadata_relations'; $workflow = new Workflow( name: 'Image Import Pipeline', tasks: [ new Task( name: TASK_FETCH_FEEDS, jobs: new DownloadFeedsJob(), ), new TaskGroup( tasks: [ new Task( name: TASK_PARSE_CATALOGS, jobs: [ new ParseCatalogsJob('source-a'), new ParseCatalogsJob('source-b'), ], ), new Task( name: TASK_PARSE_ALBUMS, jobs: new ParseAlbumsJob(), ), new Task( name: TASK_PARSE_IMAGES, jobs: new ParseImagesJob(), ), new Task( name: TASK_PARSE_METADATA, jobs: new ParseImageMetadataJob(), ), ], dependsOn: TASK_FETCH_FEEDS, ), new Task( name: TASK_SYNC_CATALOG_ALBUM_RELATIONS, jobs: new SyncCatalogAlbumRelationsJob(), dependsOn: [TASK_PARSE_CATALOGS, TASK_PARSE_ALBUMS], ), new Task( name: TASK_SYNC_ALBUM_IMAGE_RELATIONS, jobs: new SyncAlbumImageRelationsJob(), dependsOn: [TASK_PARSE_ALBUMS, TASK_SYNC_CATALOG_ALBUM_RELATIONS], ), new Task( name: TASK_SYNC_IMAGE_METADATA_RELATIONS, jobs: new SyncImageMetadataRelationsJob(), dependsOn: [TASK_PARSE_IMAGES, TASK_SYNC_ALBUM_IMAGE_RELATIONS], ), ], ); $model = $workflow->dispatch(); dump($model->id);
Testing
Run the package and application tests:
composer test
composer analyse
Contributing
Contributions are welcome. Please read CONTRIBUTING.md in the repository for guidelines.
Security
If you discover a security vulnerability, please follow the repository's security policy to report it.
Credits
- Piotr Adamczyk (maintainer)
- All contributors
License
The MIT License (MIT). Please see License File for more information.