Download the PHP package tarantool/client without Composer

On this page you can find all versions of the php package tarantool/client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package client

PHP client for Tarantool

Quality Assurance Telegram

A pure PHP client for Tarantool 1.7.1 and later, including the 2.x and 3.x series.

Features

Table of contents

Installation

This release requires PHP 8.2 or newer and rybakit/msgpack 0.11.2 or newer.

The recommended way to install the library is through Composer:

To use the Decimal type added in Tarantool 2.3, install the decimal extension. To improve performance when working with the UUID type, available since Tarantool 2.4, you can also install the uuid extension.

Creating a client

The easiest way to create a client is by using the default configuration:

The client connects to 127.0.0.1 on port 3301 using the default stream connection options. It also selects the best available MessagePack package automatically. You can configure the client in several ways, as described below.

DSN string

The client supports the following Data Source Name formats:

Some examples:

If the username, password, path or options include special characters such as @, :, / or %, they must be encoded according to RFC 3986 (for example, with the rawurlencode() function).

Array of options

It is also possible to create the client from an array of configuration options:

The following options are available:

Name Type Default Description
uri string 'tcp://127.0.0.1:3301' The connection uri that is used to create a StreamConnection object.
connect_timeout float 5.0 The number of seconds that the client waits to connect to a Tarantool server before throwing a ConnectionFailed exception.
socket_timeout float 5.0 The number of seconds that the client waits for a response from a Tarantool server before throwing a CommunicationFailed exception.
tcp_nodelay boolean true Whether the Nagle algorithm is disabled on a TCP connection.
persistent boolean false Whether to use a persistent connection.
username string The username for the user being authenticated.
password string '' The password for the user being authenticated. If the username is not set, this option will be ignored.
max_retries integer 0 The number of times the client retries an unsuccessful request. If set to 0, the client does not retry after the initial unsuccessful attempt.

Authentication and persistent connections

A persistent connection may reuse a socket opened by a previous client instance. Since authentication is tied to the socket, avoid combining persistent=true with username when a socket may be reused across client instances.

Custom build

For more extensive customization, you can build a client from the ground up:

Handlers

A handler transforms a request into a response. Once you have created a handler object, you can use it to send requests to Tarantool, for example:

The library ships with two handlers:

Middleware

Middleware is the recommended way to extend the client with custom functionality. The library includes middleware for common use cases, such as authentication and logging. See the full list in src/Middleware. Usage is straightforward:

You can also add multiple middleware components to the client. They execute in FIFO order:

The order in which you add middleware matters. The same middleware, placed in a different order, can produce different or sometimes unexpected behavior. To illustrate, consider the following configurations:

In this example, $client1 will retry an unsuccessful operation and in case of connection problems may initiate reconnection with follow-up re-authentication. However, $client2 and $client3 will perform reconnection without doing any re-authentication.

You may wonder why $client3 behaves like $client2 in this case. This is because specifying some options (via array or DSN string) may implicitly register middleware. Thus, the username/password options will be turned into AuthenticationMiddleware under the hood, making the two configurations identical.

To make sure your middleware runs first, use the withPrependedMiddleware() method:

Data manipulation

Binary protocol

The following are examples of binary protocol requests. For more detailed information and examples please see the official documentation.

Select
*Fixtures* *Code* *Output*
Insert
*Fixtures* *Code* *Output* *Space data*
Update
*Fixtures* *Code* *Output* *Space data*
Upsert
*Fixtures* *Code* *Space data*
Replace
*Fixtures* *Code* *Output* *Space data*
Delete
*Fixtures* *Code* *Output* *Space data*
Call
*Fixtures* *Code* *Output*
Evaluate
*Code* *Output*

SQL protocol

The following are examples of SQL protocol requests. For more detailed information and examples, please see the official documentation. SQL is supported starting with Tarantool 2.0.

Execute
*Code* *Output* If you need to execute a dynamic SQL statement and do not know its type, use the generic `execute()` method. It returns a `Response` object whose body contains either an array of result-set rows or an array with information about the changed rows:
Prepare
*Note that the `prepare` request is supported only as of Tarantool 2.3.2.* *Code* *Output*

User-defined types

To store complex structures inside a tuple you may want to use objects:

You can do this by extending the MessagePack type system with your own types. Write a MessagePack extension that converts your objects to and from MessagePack structures (see the msgpack.php README for details). Once you have implemented the extension, register it with the packer object:

A working example of using the user-defined types can be found in the examples folder.

Tests

To run unit tests:

To run integration tests:

Make sure to start client.lua first.

To run all tests:

If you already have Docker installed, you can run the tests in a Docker container. First, build the Docker image:

The command above builds an image named client with the PHP 8.3 runtime. You may change the default runtime by defining the PHP_IMAGE environment variable:

See a list of various images here.

Then run a Tarantool instance (needed for integration tests):

And then run both unit and integration tests:

Benchmarks

The benchmarks can be found in the dedicated repository.

License

The library is released under the MIT License. See the bundled LICENSE file for details.


All versions of client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
rybakit/msgpack Version ^0.11.2
symfony/uid Version ^5.1|^6|^7|^8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tarantool/client contains the following files

Loading the files please wait ...