Exception when using Pheanstalk lib to put new data on Beanstalkd

101 Views Asked by At

I'm using Pheanstalk library to work with Beanstalkd

I'm using this code to put new data on a tube:

$pheanstalk = Pheanstalk\Pheanstalk::create($ip);
$pheanstalk->useTube($tubename)->put($data, Pheanstalk::DEFAULT_PRIORITY, $delay);

The $tubename variable is string.But I'm getting this error:

Uncaught TypeError: Pheanstalk\Pheanstalk::useTube(): Argument #1 ($tube) must be of type Pheanstalk\Values\TubeName, string given

The name of the tube obviously will be string !, how should I pass tube's name?

The example mentioned here is also using string value for Tube's name

1

There are 1 best solutions below

0
Olivier On BEST ANSWER

The Pheanstalk::useTube() method signature changed in version 5:

public function useTube(TubeName $tube): void

So now you should pass the tube name like this:

$pheanstalk->useTube(new \Pheanstalk\Values\TubeName($tubename));