Download the PHP package zerodahero/laravel-workflow without Composer

On this page you can find all versions of the php package zerodahero/laravel-workflow. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-workflow

Laravel workflow Build Status

:warning: Looking for help maintaining!

It's been several years since I've actually used this package in a project. It's relatively low maintenance since it's mostly just an adapter for the Symfony component. It's been harder and harder to find time to spend on this project, so I'm looking for help in maintaining it, or if there's a good fit, to take over the package entirely.


This is a fork from brexis/laravel-workflow. My current needs for this package are a bit more bleeding-edge than seem to be maintainable by the other packages. Massive kudos to brexis for the original work and adaptation on this.

Use the Symfony Workflow component in Laravel

Installation

Laravel Support

Package Version Laravel Version Support
^2.0 5.x
^3.0 7.x
^3.2 8.x
^4.0 9.x

Upgrade from v3 to v4

The changes is to the PHP and Laravel version, which only PHP 8.0, 8.1 and Laravel 9 are supported in this version. If you required to use the older version, do take from version 3.4.

Upgrade from v2 to v3

The biggest changes from v2 to v3 are the dependencies. To match the Symfony v5 components, the Laravel version is raised to v7. If you're on Laravel v6 or earlier, you should continue to use the v2 releases of this package.

To match the changes in the Symfony v5 workflow component, the "arguments" config option has been changed to "property". This describes the property on the model the workflow ties to (in most circumstances, you can simply change the key name from "arguments" to "property", and set to a string instead of the previous array).

Also, the "initial_place" key has been changed to "initial_places" to align with the Symfony component as well.

Non-package Discovery

If you aren't using package discovery:

Add a ServiceProvider to your providers array in config/app.php:

Add the Workflow facade to your facades array:

Configuration

Publish the config file

Configure your workflow in config/workflow.php

A more minimal setup (for a workflow on an eloquent model).

If you are using a "multiple_state" type of workflow (i.e. you will be in multiple places simultaneously in your workflow), you will need your supported class/Eloquent model to cast the marking to an array. Read more in the Laravel docs.

You may also add in metadata, similar to the Symfony implementation (note: it is not collected the same way as Symfony's implementation, but should work the same. Please open a pull request or issue if that's not the case.)

Use the WorkflowTrait inside supported classes

Usage

Symfony Workflow Usage

Once you have the underlying Symfony workflow component, you can do anything you want, just like you would in Symfony. A couple examples are provided below, but be sure to take a look at the Symfony docs to better understand what's going on here.

Use the events

This package provides a list of events fired during a transition

You are encouraged to use Symfony's dot syntax style of event emission, as this provides the best level of precision for listening to events and prevents receiving the same event class multiple times for the "same" event. The workflow component dispatches multiple events per workflow event, and the translation into Laravel events can cause "duplicate" events to be listened to if you only listen by class name.

NOTE: these events receive the Symfony event prior to version 3.1.1, and will receive this package's events starting with version 3.1.1

You can subscribe to events in a more typical Laravel-style, although this is no longer recommended as it can result in "duplicate" events depending on how you listen to events.

Workflow vs State Machine

When using a multi-state workflow, it becomes necessary to distinguish between an array of multiple places that can transition to one place, or a situation where a subject in exactly multiple places transitions to one. Since the config is a PHP array, you must "nest" the latter situation into an array, so that it builds a transition using an array of places, rather that looping through single places.

Example 1. Exactly two places transition to one

In this example, a draft must be in both content_approved and legal_approved at the same time

Example 2. Either of two places transition to one

In this example, a draft can transition from EITHER content_approved OR legal_approved to published

Dump Workflows

Symfony workflow uses GraphvizDumper to create the workflow image. You may need to install the dot command of Graphviz

php artisan workflow:dump workflow_name --class App\\BlogPost

You can change the image format with the --format option. By default the format is png.

php artisan workflow:dump workflow_name --format=jpg

If you would like to output to a different directory than root, you can use the --disk and --path options to set the Storage disk (local by default) and path (root_path() by default).

php artisan workflow:dump workflow-name --class=App\\BlogPost --disk=s3 --path="workflows/diagrams/"

Use in tracking mode

If you are loading workflow definitions through some dynamic means (perhaps via DB), you'll most likely want to turn on registry tracking. This will enable you to see what has been loaded, to prevent or ignore duplicate workflow definitions.

Set track_loaded to true in the workflow_registry.php config file.

You can dynamically load a workflow by using the addFromArray method on the workflow registry

NOTE: There's no persistence for dynamic workflows, this package assumes you're storing those somehow (DB, etc). To use the dynamic workflows, you will need to load the workflow prior to using it. The loadWorkflow() method above could be tied into a model boot() or similar.

You may also specify an initial_places in your workflow definition, if it is not the first place in the "places" list.


All versions of laravel-workflow with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0|^8.1|^8.2
symfony/workflow Version ^6.0
symfony/process Version ^6.0
symfony/event-dispatcher-contracts Version ^2.4|^3.0
illuminate/console Version ^8.0|^9.0|^10.0
illuminate/support Version ^8.0|^9.0|^10.0
illuminate/contracts Version ^8.0|^9.0|^10.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zerodahero/laravel-workflow contains the following files

Loading the files please wait ....