Search code examples
phpqueuephp-5.6tarantool

How can i use tarantool queue in php?


There is a php library https://github.com/tarantool-php/queue, but it requires ext-tarantool, so is there any active maintainable library written purely in php, which allow us to use tarantool queue in php 5.6 or 7? Or is there any ready package for centos to install ext-tarantool for php5.6? yum install php-tarantool gives following incompatibility error

Error: Package: php-tarantool-0.1.0-19.el6.x86_64 (tarantool_1_6)
          Requires: php(zend-abi) = 20090626
          Installed: php-common-5.6.19-1.el6.remi.x86_64 (@remi-php56)
              php(zend-abi) = 20131226-64

Solution

  • I'm the author of the tarantool-php/queue library. I plan to add support for the pure PHP Tarantool client in the future, it's just not there yet. Fill free to file a ticket for that ;)

    In a meanwhile, as a workaround, you can decorate Tarantool\Client with the \Tarantool class, e.g.:

    use Tarantool\Client;
    
    class Tarantool
    {
        private $client;
    
        public function __construct(Client $client)
        {
            $this->client = $client;
        }
    
        public function call($functionName, array $args = null)
        {
            $result = $this->client->call($functionName, $args ? $args : []);
    
            return $result->getData();
        }
    }
    

    And then use it like this:

    use Tarantool\Client;
    use Tarantool\Connection\SocketConnection;
    use Tarantool\Packer\PurePacker;
    use Tarantool\Queue\Queue;
    
    $client = new Client(new SocketConnection(), new PurePacker());
    $client = new Tarantool($client);
    
    $queue = new Queue($client, 'foobar');