-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bcd0317
Showing
72 changed files
with
4,536 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: PHP Composer | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate --strict | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Check coding style via ECS | ||
run: vendor/bin/ecs check | ||
|
||
- name: Run static analysis via PHPStan | ||
run: vendor/bin/phpstan --xdebug analyse src tests | ||
|
||
- name: Run test suite | ||
run: composer run-script test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.phpunit.cache/ | ||
.phpunit.result.cache | ||
composer.phar | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 TaskValve | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Serverless Workflow Specification - PHP SDK | ||
|
||
Provides the PHP API/SPI for the [Serverless Workflow Specification](https://github.com/serverlessworkflow/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](https://github.com/serverlessworkflow/specification/tree/0.8.x). | ||
|
||
|
||
## Installation | ||
|
||
```bash | ||
composer install taskvalve/serverless-workflow-php | ||
``` | ||
|
||
## Build | ||
|
||
```php | ||
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 | ||
|
||
```php | ||
$workflow = Workflow::fromJson(file_get_contents('workflow.json')); | ||
|
||
$workflow = Workflow::fromYaml(file_get_contents('workflow.yaml')); | ||
``` | ||
|
||
### Convert to JSON/YAML | ||
|
||
```php | ||
$json = $workflow->toJson(); | ||
|
||
$yaml = $workflow->toYaml(); | ||
``` | ||
|
||
## Validate | ||
|
||
```php | ||
use Serverless\Workflow\WorkflowValidator; | ||
|
||
WorkflowValidator::validate($workflow); | ||
``` | ||
|
||
The `validate` method will raise an exception if the provided workflow does not comply with the specification. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "taskvalve/serverless-workflow-php", | ||
"type": "library", | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"Serverless\\Workflow\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Richard McDaniel", | ||
"email": "richard.lee.mcdaniel@gmail.com" | ||
} | ||
], | ||
"require-dev": { | ||
"phpstan/phpstan": "^1.9", | ||
"phpunit/phpunit": "^10.4", | ||
"rector/rector": "^0.18.10", | ||
"symplify/easy-coding-standard": "^11.1" | ||
}, | ||
"require": { | ||
"symfony/yaml": "^6.3", | ||
"phpdocumentor/reflection-docblock": "^5.3", | ||
"swaggest/json-schema": "^0.12.42" | ||
}, | ||
"scripts": { | ||
"rector": "vendor/bin/rector", | ||
"ecs": "vendor/bin/ecs check --fix", | ||
"stan": "vendor/bin/phpstan analyse src tests", | ||
"test": "phpunit --testdox" | ||
} | ||
} |
Oops, something went wrong.