PHPackages                             mehrdadmahdian/php-workflow-core - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mehrdadmahdian/php-workflow-core

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mehrdadmahdian/php-workflow-core
================================

A Simple PHP Engine for Simple Business Processes

20PHP

Since Oct 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mehrdadmahdian/php-workflow-core)[ Packagist](https://packagist.org/packages/mehrdadmahdian/php-workflow-core)[ RSS](/packages/mehrdadmahdian-php-workflow-core/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

PHP Workflow Engine For Simple Business Workflows
-------------------------------------------------

[](#php-workflow-engine-for-simple-business-workflows)

### (Under Development - Do Not Use This)

[](#under-development---do-not-use-this)

 This is an amazing workflow engine to interact with your simple business workflows.

This core build your business workflow model using simple activity array of configuration. Code client can run different actions on built process model and update model status.

Process Main Concepts
=====================

[](#process-main-concepts)

[![alt Simple Process Example](spe.jpg)](spe.jpg)

It is assumed that each process is made up of multiple activity blocks which are connected to each other using transition flows.

- Each activity has its own unique name. This is the key to reach activity element.
- Each activity could be connected to multiple sources. Sources must be in type of activity.
    - An activity could have no source. It means on start action, this activity's status will be updated to `active` status
- Each activity could be connected to multiple targets. Targets must be in type of activity.
    - An activity could have no target. It means process is in last activity state.
- Each activity has its current status. statuses may be between one of these statuses: `active`, `inactive`, `done`.
- At the start of process all activities have `inactive` status.
- When activity target is triggered, the target activity goes to `active` status.
- Each process only could have one `active` activity at a time.
- Each activity could have its own observers. while updating activity status, observer will be notified.
- This engine does not support conditional or parallel flows.

Installation
============

[](#installation)

Simply run composer require command to include this library in your project

```
    composer require mehrdadmahdian/php-workflow-core
```

to access to library feature, this namespace should be used: `MehrdadMahdian\PhpWorkflowCore`

Usage
=====

[](#usage)

An example of process configuration array is introduced here. This is a process with 3 activities which is not started yet and all activities has null or inactive status. [![alt Simple Process Example](simple.jpg)](simple.jpg)Code Client decided where to load configuration. It can be loaded from permanent storage, or it could be loaded statically form a file.

```
    $configuration = [
       'activities' => [
           [
               'name' => 'act1',
               'sources' => [],
               'targets' => ['act2'],
//               'status'  => ElementInterface::STATUS_INACTIVE,
               'observers' => [ActivitySampleObserver::class],
               'extra-actions' => [
                    SomeActionTypeWhichImplementsActionInterface1::class,
                    SomeActionTypeWhichImplementsActionInterface2::class
                ]
           ],
           [
               'name' => 'act2',
               'sources' => ['act1'],
               'targets' => ['act3'],
//               'status'  => ElementInterface::STATUS_INACTIVE
           ],
           [
               'name' => 'act3',
               'sources' => ['act2'],
               'targets' => [],
               'status'  => ElementInterface::STATUS_INACTIVE
           ],
       ]
    ];
```

Process model could be built using package built-in facade method.

```
    use MehrdadMahdian\PhpWorkflowCore\PhpWorkflowCoreFacade;
    $model = PhpWorkflowCoreFacade::buildProcessModel($configuration);
```

Actions
-------

[](#actions)

client could run engine action using built-in facade too:

```
    use MehrdadMahdian\PhpWorkflowCore\PhpWorkflowCoreFacade;
    $model = PhpWorkflowCoreFacade::runEngineAction($model, $action, $params);
```

after each action type, updated model is accessible. Updated model data must be persisted by client if it is needed.

to find thant which actions each activity has, we can use this code:

```
    use MehrdadMahdian\PhpWorkflowCore\PhpWorkflowCoreFacade;
    $model = PhpWorkflowCoreFacade::getActivityActions($model, $myActivityKey);
```

it will return list of available actions with their required parameters.

Two built-in actions are supported in this library and each one has its own params.

### Start Action

[](#start-action)

No Parameter is needed in this type of action

```
    use MehrdadMahdian\PhpWorkflowCore\PhpWorkflowCoreFacade;
    $model = PhpWorkflowCoreFacade::runEngineAction(
        $model, //suppose that model is defined previously in the code. mdoel is in type of ModelInterface
        'start'
    );
```

### Transition Action

[](#transition-action)

```
    use MehrdadMahdian\PhpWorkflowCore\PhpWorkflowCoreFacade;
    $model = PhpWorkflowCoreFacade::runEngineAction(
        $model,
        'transition',
        ['currentActivityKey' => 'act1', 'targetActivityKey' => 'act2']
     );
```

Extra Actions
-------------

[](#extra-actions)

Inside of built in actions of workflow core, we can run desired action which is implements `ActionInterface`. To do that, action class must be fed to `runEngineAction` like this:

```
    use MehrdadMahdian\PhpWorkflowCore\PhpWorkflowCoreFacade;
    $parameters = [
        //key: //value,
        //key2: //value2,
        ...
    ];
    $model = PhpWorkflowCoreFacade::runEngineAction(
        $model,
        \Path\To\My\Custom\Action::class,
        $parameters
     );
```

Observers
---------

[](#observers)

No description yet.

Contributing
============

[](#contributing)

if you want to contribute in this project please follow this instruction.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a PR on this repository
6. Wait to accept and merge the PR

License
=======

[](#license)

Distributed under the MIT License.

Contact
=======

[](#contact)

Mehrdad Mahdian: [Gmail](escherchia88@gmail.com)

Project Link: [PHP Workflow Core](https://github.com/escherchia/process-engine-core)

Todo
====

[](#todo)

- missing tests
- get available actions from activity
- support published configurations file.
- configuration validator
- action validator implementation

Suggested Features to contribute
================================

[](#suggested-features-to-contribute)

- wrapper for laravel and other php frameworks

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a32f4173fb838f6bfc8078a629d4df085840cb676a5d9948bfaed3b72ff4acac?d=identicon)[mehrdad](/maintainers/mehrdad)

---

Top Contributors

[![mehrdadmahdian](https://avatars.githubusercontent.com/u/70692509?v=4)](https://github.com/mehrdadmahdian "mehrdadmahdian (16 commits)")

### Embed Badge

![Health badge](/badges/mehrdadmahdian-php-workflow-core/health.svg)

```
[![Health](https://phpackages.com/badges/mehrdadmahdian-php-workflow-core/health.svg)](https://phpackages.com/packages/mehrdadmahdian-php-workflow-core)
```

###  Alternatives

[stuttter/wp-user-profiles

A sophisticated way to edit users in WordPress

11219.3k1](/packages/stuttter-wp-user-profiles)[fof/analytics

Tracks analytics using Google Analytics, Google Optimize/GTM and Matomo

3543.1k](/packages/fof-analytics)[chrico/wp-fields

Package which provides some re-usable fields for WordPress.

1981.2k](/packages/chrico-wp-fields)[aertmann/history

An improved history backend module for Neos

1070.2k](/packages/aertmann-history)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
