PHPackages                             teamzac/laravel-workflows - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. teamzac/laravel-workflows

ActiveLibrary[Queues &amp; Workers](/categories/queues)

teamzac/laravel-workflows
=========================

A Laravel package for running queued, multi-step workflows

v0.4.0(1mo ago)3109MITPHPPHP ^8.2CI failing

Since Aug 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/teamzac/laravel-workflows)[ Packagist](https://packagist.org/packages/teamzac/laravel-workflows)[ Docs](https://github.com/teamzac/laravel-workflows)[ RSS](/packages/teamzac-laravel-workflows/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (7)Versions (11)Used By (0)

A Laravel 8+ package for running multi-step, queued workflows
=============================================================

[](#a-laravel-8-package-for-running-multi-step-queued-workflows)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4e1181d90f4d080bc6b4df5c02c931e1fbe004fab0cf669074259176b9b41caf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7465616d7a61632f6c61726176656c2d776f726b666c6f77732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teamzac/laravel-workflows)[![Total Downloads](https://camo.githubusercontent.com/7790e74da16156ff757b6a1abdce750761ded848cb85da27aace0ac99401fe26/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7465616d7a61632f6c61726176656c2d776f726b666c6f77732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teamzac/laravel-workflows)

Pipelines are a powerful tool in Laravel apps, but sometimes you need to perform longer running tasks that may be split into multiple steps with better support for handling situations where errors occur end you need to restart from the current point. This package helps with those types of workflows.

This package is available for public use, but keep in mind that it's built for our specific use case at this time. It has been extracted from an older app and updated a bit for more general use. There are probably some edge cases that we haven't accounted for, and there might be some *duh* features that we haven't included yet. It may not fit all of your needs. If you'd like to contribute to make it better, that'd be awesome! But please reach out beforehand in case what you need doesn't fit with our use for the package.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require teamzac/laravel-workflows
```

This package uses auto-discovery, so you do not need to include it in your `config/app.php`.

You can publish the config and tweak settings including the name of the workflow instance table.

```
php artisan vendor:publish --provider="TeamZac\Workflow\WorkflowServiceProvider"
```

Once you're ready, migrate the database to create the `workflow_instances` table. You can also publish the migration file if you wish to modify it. The table name can be changed in the config.

```
php artisan migrate
```

Concepts
--------

[](#concepts)

### Workflow

[](#workflow)

A `Workflow` is comprised of one or more `WorkflowStep`s. When you run a Workflow, this package will iterate through each WorkflowStep. If an unhandled error is encountered, the Workflow will be paused; otherwise, it will proceed to the next step until there are no more.

### WorkflowStep

[](#workflowstep)

A WorkflowStep is one of potentially many tasks that need to be handled during a Workflow.

### WorkflowInstance

[](#workflowinstance)

A WorkflowInstance is a concrete instance of a Workflow, which often includes specific data on which the Workflow will perform actions. In this package, a WorkflowInstance is represented via an Eloquent model, and is stored in your database.

### WorkflowManager

[](#workflowmanager)

This is a central repository for Workflows in your app. You should register your Workflows in a service provider. It provides convenient access to run and manage Workflows.

Usage
-----

[](#usage)

### Creating a Workflow

[](#creating-a-workflow)

Before you can run a Workflow, you'll need to create one. You can create a new subclass of `TeamZac\Workflows\AbstractWorkflow` where ever you'd like. You can also use the built-in generators to quickly scaffold a new Workflow:

```
// example
php artisan make:workflow App\\Workflows\\TestWorkflow
```

The AbstractWorkflow subclass does a good deal of work for you, so all you need to do is define the `WorkflowStep`s that should be performed:

```
