Download the PHP package rhaarhoff/workflow without Composer
On this page you can find all versions of the php package rhaarhoff/workflow. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package workflow
Laravel Workflow Generator
Description
This package provides a way for generating workflow definitions & workflows from those definitions.
For an example project on how this works visit the workflow-example github page.
Installation
Require this package with Composer using the following command:
After updating Composer, add the service provider to the providers
array in config/app.php
:
Run the dump-autoload
command:
In Laravel, instead of adding the service provider in the config/app.php
file, you can add the following code to your app/Providers/AppServiceProvider.php
file, within the register()
method:
Commands
Below you can find all the commands that you can use, including the parameters that you can specify.
How it works
A workflow is much like a state machine (see here for more information). Basically a workflow is divided into multiple 'states' or 'steps' with each step receiving an input, doing some logic, and returning an output. The ultimate goal of a workflow is to receive input, go through a defined number of steps through transitions and give an output at the end.
Setting up a definition file
Once you run the command to create a definition file, like php artisan workflow:create Example
you will see something like this:
What does this all mean? See the table below
In order to create a working definition file, all of the information needs to be provided within the placeholder fields. For a decent example on all capabilities of a workflow definition file, see below:
You can see there are three transitions within this workflow:
- GetExistingUserOrNull is the start state and transitions to ShouldUpdateUser only if the condition specified is met, otherwise it transitions to End.
- ShouldUpdateUser transitions to UpdateUser only if the condition is met, otherwise transitions to End.
- UpdateUser only transitions to End with no condition specified.
Additional information on workflow states:
- Each workflow state takes zero or more parameters as input and can only specify one output.
- Make sure the startState specified, is the first workflow state you define.
- For every workflow transition condition, make sure to use when referencing a variable.
- Make sure for every variable you define in the workflow, that an import/use is specified.
- You can't define a circular transition. (state1 -> state2 -> state3 -> state1)
- The use of the following primitive types are allowed:
- string
- bool
- integer
- float
When you have finished setting up your definition files, run the following command to generate the code:
A base Workflow class will be generated that all other workflow's extend from.
For each definition file, it will generate a Base Class as well as a class that Extends the base class. Your file structure for a working definition file should then look something like this:
License
The Laravel Workflow generator is open-sourced software licensed under the MIT license.