Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ProcessMaker/nayra
Nayra is a BPMN workflow engine in PHP. Utilize it in your own projects to have your own complex workflow capabilities.
https://github.com/ProcessMaker/nayra
Last synced: 3 months ago
JSON representation
Nayra is a BPMN workflow engine in PHP. Utilize it in your own projects to have your own complex workflow capabilities.
- Host: GitHub
- URL: https://github.com/ProcessMaker/nayra
- Owner: ProcessMaker
- License: apache-2.0
- Created: 2018-03-20T16:57:17.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2023-11-13T16:34:45.000Z (12 months ago)
- Last Synced: 2024-05-04T01:42:12.103Z (6 months ago)
- Language: PHP
- Size: 1.43 MB
- Stars: 111
- Watchers: 35
- Forks: 31
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- php-awesome - Nayra - BPMN workflow engine (类库 / 工作流)
README
# ProcessMaker Nayra
ProcessMaker Nayra is a package that provides base classes to implement a process execution engine.
This includes patterns to implement activities, events and gateways.## How to execute a process
Load a BPMN definition
```
$bpmnRepository = new BpmnDocument();
$bpmnRepository->setEngine($this->engine);
$bpmnRepository->setFactory($this->repository);
$bpmnRepository->load('files/ParallelGateway.bpmn');
```
![ParallelGateway diagram](/docs/diagrams/ParallelGateway.svg "ParallelGateway diagram")Get a reference to the process
```
$process = $bpmnRepository->getProcess('ParallelGateway');
```
Create a data storage
```
$dataStore = $this->repository->createDataStore();
```
Create a process instance
```
$instance = $this->engine->createExecutionInstance($process, $dataStore);
```
Trigger the start event
```
$start = $bpmnRepository->getStartEvent('StartEvent');
$start->start($instance);
```
![Start Event](/docs/diagrams/ParallelGateway_1.svg "Start Event")Execute tokens and run to the next state
```
$this->engine->runToNextState();
```
One token arrives to the first task
```
$firstTask = $bpmnRepository->getScriptTask('start');
$token = $firstTask->getTokens($instance)->item(0);
```
![First task](/docs/diagrams/ParallelGateway_2.svg "First task")Complete the first task
```
$startActivity->complete($token);
```
Execute tokens and run to the next state
```
$this->engine->runToNextState();
```
One token arrives to the second task and one to the third task
```
$secondTask = $bpmnRepository->getScriptTask('ScriptTask_1');
$token1 = $secondTask->getTokens($instance)->item(0);
$thirdTask = $bpmnRepository->getScriptTask('ScriptTask_2');
$token2 = $thirdTask->getTokens($instance)->item(0);
```
![Second task and third task](/docs/diagrams/ParallelGateway_3.svg "Second task and third task")## License
ProcessMaker Nayra is open-sourced software licensed under the [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) license.