定制 serverlessworkflow/sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

serverlessworkflow/sdk

最新稳定版本:1.0.0

Composer 安装命令:

composer require serverlessworkflow/sdk

包简介

Provides the PHP API/SPI for the Serverless Workflow Specification.

README 文档

README

Provides the PHP API/SPI for the Serverless Workflow Specification.

With the SDK you can:

  • Programmatically build workflow definitions
  • Parse workflow JSON and YAML definitions
  • Validate workflow definitions

Status

Current SDK version conforms to the Serverless Workflow specification v0.8.

Installation

composer install serverlessworkflow/sdk

Build

use Serverless\Workflow\Action;
use Serverless\Workflow\ActionDataFilter;
use Serverless\Workflow\FunctionDef;
use Serverless\Workflow\FunctionRef;
use Serverless\Workflow\OperationState;
use Serverless\Workflow\Workflow;

$workflow = new Workflow([
    'id' => 'greeting',
    'name' => 'Greeting Workflow',
    'description' => 'Greet Someone',
    'version' => '1.0',
    'specVersion' => '0.8',
    'start' => 'Greet',
    'states' => [
        new OperationState([
            'name' => 'Greet',
            'type' => 'operation',
            'actions' => [
                new Action([
                    'functionRef' => new FunctionRef([
                        'refName' => 'greetingFunction',
                        'arguments' => [
                            'name' => '${ .person.name }',
                        ],
                    ]),
                    'actionDataFilter' => new ActionDataFilter([
                        'results' => '${ .greeting }',
                    ]),
                ]),
            ],
            'end' => true,
        ]),
    ],
    'functions' => [
        new FunctionDef([
            'name' => 'greetingFunction',
            'operation' => 'file://myapis/greetingapis.json#greeting',
        ]),
    ],
]);

Parse

Convert from JSON/YAML source

$workflow = Workflow::fromJson(file_get_contents('workflow.json'));

$workflow = Workflow::fromYaml(file_get_contents('workflow.yaml'));

Convert to JSON/YAML

$json = $workflow->toJson();

$yaml = $workflow->toYaml();

Validate

use Serverless\Workflow\WorkflowValidator;

WorkflowValidator::validate($workflow);

The validate method will raise an exception if the provided workflow does not comply with the specification.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2023-11-23