With PHP SDK 4.1.6, I’m able to use ignbinary with this Transcoder. flags are ignored.
<?php
declare(strict_types=1);
namespace Couchbase;
class IgbinaryTranscoder implements Transcoder
{
private static ?IgbinaryTranscoder $instance;
public static function getInstance(): Transcoder
{
if (!isset(self::$instance)) {
self::$instance = new IgbinaryTranscoder();
}
return self::$instance;
}
/**
*
* @param mixed $value document
*
* @return array tuple of encoded value with flags for network layer
*/
public function encode($value): array
{
return [
igbinary_serialize($value), 0
];
}
/**
*
* @param string $bytes encoded data
* @param int $flags flags from network layer, that describes format of the encoded data
*
* @return mixed decoded document
*/
public function decode(string $bytes, int $flags)
{
return igbinary_unserialize($bytes);
}
}
calling code is
$tx = IgbinaryTranscoder::getInstance();
$uoptions = new UpsertOptions();
$uoptions->transcoder($tx);
$ret = $collection->upsert($key, '{"test":"test"}', $uoptions);
$options = new GetOptions();
$options->transcoder($tx);
$ret = $collection->get($key, $options);
print($ret->content());