PHP client for Tarantool
Installation
The recommended way to install the library is through Composer:
$ composer require tarantool/client:@devUsage
use Tarantool\Client\Client;
use Tarantool\Client\Connection\StreamConnection;
use Tarantool\Client\Packer\PurePacker;
$conn = new StreamConnection();
// or
// $conn = new StreamConnection('tcp://127.0.0.1:3301');
// $conn = new StreamConnection('tcp://127.0.0.1:3301', ['socket_timeout' => 5.0, 'connect_timeout' => 5.0]);
// $conn = new StreamConnection('unix:///tmp/tarantool_instance.sock');
$client = new Client($conn, new PurePacker());
// or
// $client = new Client($conn, new PeclPacker());
// $client = new Client($conn, new PeclLitePacker());
$space = $client->getSpace('my_space');
$result = $space->select();
var_dump($result->getData());
$result = $client->evaluate('return ...', [42]);
var_dump($result->getData());
$result = $client->call('box.stat');
var_dump($result->getData());Note
Using packer classes provided by the library require to install additional dependencies, which are not bundled with the library directly. Therefore, you have to install them manually. For example, if you plan to use PurePacker, install the rybakit/msgpack package. See the "suggest" section of composer.json for other alternatives.
Tests
To run unit tests:
$ phpunit --testsuite UnitTo run integration tests:
$ phpunit --testsuite IntegrationMake sure to start client.lua first.
To run all tests:
$ phpunitIf you already have Docker installed, you can run the tests in a docker container. First, create a container:
$ ./dockerfile.py | docker build -t client -The command above will create a container named client with PHP 5.6 runtime.
You may change the default runtime by defining the IMAGE environment variable:
$ IMAGE='php:7.0-cli' ./dockerfile.py | docker build -t client -See a list of various images here.
Then run Tarantool instance (needed for integration tests):
$ docker run -d --name tarantool -v $(pwd):/client tarantool/tarantool \
/client/tests/Integration/client.luaAnd then run both unit and integration tests:
$ docker run --rm --name client --link tarantool -v $(pwd):/client -w /client clientLicense
The library is released under the MIT License. See the bundled LICENSE file for details.

