PHP SDK: How do I set a Collection-type execution variable?

Hi,

I’m trying to iterate over a collection with a multi instance loop, but I fail at setting a correct variable that has the type Collection. Executing my BPMN workflow results in an error message: Variable 'articlePackages' is not from type 'Collection'.

The variable I pass to the putExecutionVariable() function is an instance of a custom collection class which is written in PHP and looks like this:

class TestCollection implements \IteratorAggregate, \Countable
{
    private $test;

    public function __construct()
    {
        $this->test = ['a', 'b', 'c'];
    }

    public function getIterator()
    {
        return new \ArrayIterator($this->test);
    }

    public function count()
    {
        return count($this->test);
    }
}

But passing a variable having the type TestCollection doesn’t work for the engine. Unlike in Java, there is no Collection base class that I can inherit from.

So how do I pass a Collection variable to the execution in PHP?

Thanks for your advices. :slight_smile:

Hi @dominikb,

The PHP SDK community extension is currently not actively maintained, and most of the forum regulars have little experience with PHP. As the PHP client is a client for Camunda’s REST API, we can certainly help you with how the REST requests should look like, but you’ll have to figure out the PHP side of things yourself.

Cheers,
Thorben

Hi,

thanks for your answer. Should I start a new thread for asking how the general REST call should look like?

As you like. A separate post is probably cleaner.