Getting started with workflows in PHP

For a large project at work, we need to integrate or develop a workflow engine.  I worked a little bit with workflow engines in the past, but the subject is way to big and complex for me to claim any expertise in it.

So, I am looking at what’s available these days and what are our options.  This post is a collection of initial links and thoughts, and it’s goal is mostly to document my research process and findings, and not to provide any answers or solutions yet.

First things first.  What am I looking for?

  • PHP technology stack.  The project is in PHP, and all our in-house expertise is in PHP, so for now I’m not going to consider anything too far out.  Ideally, something for CakePHP framework.
  • Web-based user interface or configuration files.  We will need to provide clients with the way to manage the workflows, so either we need a web interface (ideally, for non-technical people), or at least some form of configuration files (most clients who will use it either have their own development teams or will use us to set things up and manage them later).
  • Open Source software.  The workflow engine will be embedded into our own projects and products, and at this time we don’t want to rely on proprietary options.  BSD or MIT licenses preferable.
  • Free.  This is not a hard requirement, but rather a nice to have.

The above is not workflow specific, but a general approach to evaluating components that we need.  Now for the workflow-specific things:

  • Process management.  We don’t have any hard requirements currently, but some use case scenarios include approvals (content publishing, purchasing, registrations, payments, and so on).
  • Versioning.  Any workflow that is defined and activated will eventually change.
  • Visualization.   In the ideal world, we’d have a visual editor to create and edit workflows, but at the very least, existing workflows should be presented in some visual form, like a graph or a chart.
  • Failures and re-runs.  Workflow runs will fail occasionally.  The solution should handle failures gracefully.  More so, it should allow to re-run either the full workflow or a part of it.  Re-runs should be supported for successful executions too, not just the failed ones.
  • Multiple trigger mechanisms.  Workflows can be triggered based on time (either on specific dates and times, periodically, or based on time since some conditions).  Data change (creating a new record, editing an existing one, etc) should be able to trigger a workflow run.  Also, workflow should be triggerable manually, as in the case above, with re-runs.
  • Flexible actions support.  Workflow actions should be easy to create, whether it’s a message sending, a webhook/web request, or something more specific.
  • Parallel execution.  There might be multiple workflows defined for the same record, and they might be executed in parallel, independently of each other.
  • Logging.  It should be crystal clear from the logs what triggered which workflow run, what was the status (success, failure), what was changed/done, etc.
  • Standard compliance.  If there are any standards in this domain, it’d be nice if the solution was compliant with them, in order to minimize the reinvention of the wheel and to increase the interoperability with other tools.

I think that’s enough for now.  The above might change as I learn more.

Before diving into any specific solutions and comparisons, it’d be nice to have a better understanding of what’s available and to get some terminology right.  As I said, I’m not an expert in this field, so for now even coming up with Google search terms is a challenge.  Let’s get some Wikipedia references here (some of these I’ve read, and some of these I’m still chewing up):

OK, so with the above, I’m starting to build up my terminology vocabulary and it’s easier to find things now.

From the get-go look at things, it seems that BPMN v2.0 is the standard to consider seriously.  While there are many workflow and business process management options to choose from, BPMN v2.0 engines are fewer and more clearly defined.

That’s more than enough theoretical material for the first time.  Let’s get a bit more practical.  What’s out there, especially in the PHP world?

It’s too early to make a decision yet, but if I had to right now, I’d probably go with Workflower, implementing a BPMN v2.0 approach.

 

 

 

7 thoughts on “Getting started with workflows in PHP”


  1. Hi, have you ever done a follow-up on this article? What have you decided upon? Interested to hear your progress. Still have not found one that is CodeIgniter compatible, which is what I need.


    1. I haven’t done a follow-up just yet. At the time, it looked like BPMNv2 would be the best approach, so I read most of the spec. I tried a few libraries implementing it, but none really did everything I wanted, so I even did a small proof of concept implementation myself. That thing is much more complex than it even looks. :)

      For the last few months the requirement was on hold so I didn’t spend much time on the subject. However, at some point, there was a discussion for a simpler workaround and I was thinking of the Request Tracker (aka RT3 or RT4) and their implementation of LIfeCycles. Of course, the system is written in Perl, but porting just that bit of functionality to PHP might not be a lot of work. Have a look at this page for more information: https://docs.bestpractical.com/rt/4.4.1/customizing/lifecycles.html

      I’m sure once I get back to that requirement, I’ll have a lot more to say, and probably even some code to share. Please let me know if you stumble upon anything useful on the subject.

Leave a Comment