PHP code example of zenaton / zenaton-php

1. Go to this page and download the library: Download zenaton/zenaton-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zenaton / zenaton-php example snippets


Zenaton\Client::init('YourApplicationId', 'YourApiToken', 'YourApplicationEnv');

use Zenaton\Interfaces\TaskInterface;
use Zenaton\Traits\Zenatonable;

class HelloWorldTask implements TaskInterface
{
    public function handle()
    {
        echo "Hello World\n";

        return mt_rand(0, 1);
    }
}

(new HelloWorldTask())->dispatch();

use Zenaton\Interfaces\WorkflowInterface;
use Zenaton\Traits\Zenatonable;

class MyFirstWorkflow implements WorkflowInterface
{
    use Zenatonable;

    public function handle()
    {
        $n = (new HelloWorldTask())->execute();
        if ($n > 0) {
            (new FinalTask())->execute();
        }
    }
}

(new MyFirstWorkflow())->dispatch();