bingo-soft / jabe

PHP framework for workflow and process automation
MIT License
15 stars 5 forks source link

How to use it? #2

Open netyum opened 1 year ago

netyum commented 1 year ago

I want to use this, but I don't know how, is there documentation, or a quick start example

bingo-soft commented 1 year ago

@netyum Hi, there! There are multiple integration tests. Please, have a look at them. To run them build database first. Script for database resides here - [https://github.com/bingo-soft/jabe/blob/main/src/Resources/Db/Postgresql/V1_0.sql]() Please, pay attention that at the moment it supports only Postgresql (in future I plan to support other databases as well). Besides, you have to have several environmental variables, listed here - [https://github.com/bingo-soft/jabe/blob/main/src/ProcessEngineConfiguration.php#L365-L378]() . The most important ones are DB_JABE_DRIVER, DB_JABE_HOST, DB_JABE_PORT, DB_JABE_NAME, DB_JABE_USER and DB_JABE_PASSWORD . These are used to establish database connection.

For example, in my case I created database engine, ran the script to create all necessary tables and set environment variables to these values:

DB_JABE_DRIVER=pdo_pgsql
DB_JABE_HOST=127.0.0.1
DB_JABE_PORT=5432
DB_JABE_NAME=postgres
DB_JABE_USER=postgres

Also, pay attention that this engine does not have REST API at the moment and you have to use its raw API. For example, in my internal application I communicate with the engine through Kafka events. I have a worker, that is listening commands to the engine - commands like "start process by key", "complete task", "claim task" and others. And when these commands reach to the worker, I do it like so. First of all, in my bootstrap file, I initiate the engine:

$conf = \Jabe\ProcessEngineConfiguration::createProcessEngineConfigurationFromResource(realpath('Resources/engine.cfg.xml'));
$di->set("process_engine", $conf->buildProcessEngine()); // in this case di - is my dependency injection container, that stores reference to process engine

Then in my command handler I do it like so:

$processEngine = $di->get("process_engine"); // di again is dependency injection container
$processEngine->getRuntimeService()->startProcessInstanceByKey($key, $variables); //key is process key, variables are process variables you want to set

So, as you can see, I interract with the process engine using its own API. If you have any other questions, you can reach me via telegram https://t.me/jabe_engine

netyum commented 1 year ago

php8.1

composer require bingo-soft/jabe -vvv

engine.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
  <properties id="processEngineConfiguration" class="Jabe\Impl\Cfg\StandaloneProcessEngineConfiguration">

    <property name="dbUrl" value="${database.url}" />
    <property name="dbDriver" value="${database.driver}" />
    <property name="dbUsername" value="${database.username}" />
    <property name="dbPassword" value="${database.password}" />

    <!-- Database configurations -->
    <property name="databaseSchemaUpdate" value="true" />

    <!-- Empty beans map to for testing purpose -->
    <property name="beans">
      <map/>
    </property>

    <!-- job executor configurations -->
    <property name="jobExecutorActivate" value="true" />

    <property name="bpmnStacktraceVerbose" value="false" />

    <!-- turn off metrics reporter -->
    <property name="dbMetricsReporterActivate" value="false" />
    <property name="telemetryReporterActivate" value="false" />
    <property name="taskMetricsEnabled" value="false" />

    <!-- mail server configurations -->
    <property name="mailServerPort" value="${mail.server.port}" />
    <property name="history" value="${history.level}" />

    <property name="authorizationCheckRevokes" value="${authorizationCheckRevokes}"/>

    <property name="dbBatchProcessing" value="${dbBatchProcessing}"/>

    <!--<property name="idGenerator" ref="uuidGenerator" />-->

    <!-- telemetry configuration -->
    <property name="telemetryEndpoint" value="http://localhost:8081/pings"/>

  </properties>

  <!--<bean id="uuidGenerator" class="StrongUuidGenerator" />-->

</configuration>

test.php

<?php

require 'vendor/autoload.php';

$conf = \Jabe\ProcessEngineConfiguration::createProcessEngineConfigurationFromResource(realpath('./engine.cfg.xml'));
$process_engine = $conf->buildProcessEngine(); // in this case di - is my dependency injection container, that stores reference to process engine

var_dump($process_engine);
export DB_JABE_DRIVER=pdo_pgsql
export DB_JABE_HOST=127.0.0.1
export DB_JABE_PORT=5432
export DB_JABE_NAME=postgres
export DB_JABE_USER=postgres
export DB_JABE_PASSWORD=postgres

run

php test.php

$ php test.php 
PHP Deprecated:  Return type of Util\Reflection\Property\PropertyTokenizer::next() should either be compatible with ArrayIterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/util/src/Reflection/Property/PropertyTokenizer.php on line 60

Deprecated: Return type of Util\Reflection\Property\PropertyTokenizer::next() should either be compatible with ArrayIterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/util/src/Reflection/Property/PropertyTokenizer.php on line 60
PHP Deprecated:  Optional parameter $properties declared before required parameter $className is implicitly treated as a required parameter in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/el/src/ExpressionFactory.php on line 22

Deprecated: Optional parameter $properties declared before required parameter $className is implicitly treated as a required parameter in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/el/src/ExpressionFactory.php on line 22
PHP Deprecated:  Jabe\Impl\Pvm\Process\ActivityImpl implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Pvm/Process/ActivityImpl.php on line 15

Deprecated: Jabe\Impl\Pvm\Process\ActivityImpl implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Pvm/Process/ActivityImpl.php on line 15
PHP Deprecated:  Jabe\Impl\Pvm\Process\TransitionImpl implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Pvm/Process/TransitionImpl.php on line 13

Deprecated: Jabe\Impl\Pvm\Process\TransitionImpl implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Pvm/Process/TransitionImpl.php on line 13
PHP Deprecated:  Jabe\Impl\Pvm\Process\ProcessDefinitionImpl implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Pvm/Process/ProcessDefinitionImpl.php on line 16

Deprecated: Jabe\Impl\Pvm\Process\ProcessDefinitionImpl implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Pvm/Process/ProcessDefinitionImpl.php on line 16
PHP Deprecated:  Return type of Jabe\Variable\Impl\VariableMapImpl::serialize() should either be compatible with ArrayObject::serialize(): string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Variable/Impl/VariableMapImpl.php on line 160

Deprecated: Return type of Jabe\Variable\Impl\VariableMapImpl::serialize() should either be compatible with ArrayObject::serialize(): string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Variable/Impl/VariableMapImpl.php on line 160
PHP Deprecated:  Jabe\Impl\Persistence\Entity\FormDefinitionEntity implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Persistence/Entity/FormDefinitionEntity.php on line 12

Deprecated: Jabe\Impl\Persistence\Entity\FormDefinitionEntity implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Persistence/Entity/FormDefinitionEntity.php on line 12
PHP Deprecated:  Jabe\Impl\Batch\BatchJobDeclaration implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Batch/BatchJobDeclaration.php on line 20

Deprecated: Jabe\Impl\Batch\BatchJobDeclaration implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /Users/wayhood/Works/php/bpm/vendor/bingo-soft/jabe/src/Impl/Batch/BatchJobDeclaration.php on line 20
NULL

Deprecated very much

bingo-soft commented 1 year ago

@netyum Thank you! I'll fix it in the nearest release.

bingo-soft commented 1 year ago

@netyum Hi there! I fixed this issue with Serializable interface in new major release. Please, update and check it out. BTW, you also seem to have very strict error reporting options in PHP. Probably, you should suppress warnings, notices and deprecation messages. But it is ok to test it under current settings as well. Good luck!

jrace1 commented 1 year ago

Good morning, I am also interested and would like to collaborate, but I could not even install, if I could create a documentation would be important for the project.

bingo-soft commented 1 year ago

@jrace1 You are very much welcome! As for installation, please, follow our telegram group - https://t.me/jabe_engine. We will go step by step the process of running the engine