PHP Thin Client
How to install and use the GridGain 8 PHP thin client: creating a client instance, connecting to a cluster, key-value operations, scan and SQL queries, SSL/TLS, and authentication.
Prerequisites
php-xml module
PHP Multibyte String extension. Depending on your PHP configuration, you may need to additionally install/configure it.
Installation
The PHP thin client is shipped as a Composer package and a zip archive. Use any of the methods to install the client in your environment.
Using Composer
composer require gridgain/gridgain-clientTo use the client in your application, include the vendor/autoload.php file, generated by Composer, to your source code, eg.
require_once __DIR__ . '/vendor/autoload.php';Using ZIP Archive
The thin client can be installed from the zip archive available for download from the GridGain website:
Download the GridGain PHP Thin Client archive.
Unpack the archive and navigate to the root folder.
Use the command below to install the package.
To use the client in your application, include the vendor/autoload.php file, generated by Composer, to your source code.
Creating a Client Instance
All operations of the PHP thin client are performed through a Client instance. You can create as many Client instances as needed. All of them will work independently.
Connecting to Cluster
To connect to a cluster, define a ClientConfiguration object with the desired connection parameters and use the Client.connect(...) method.
The ClientConfiguration constructor accepts a list of node endpoints. At least one endpoint must be specified. If you specify more than one, the thin client will use them for failover purposes.
If the client cannot connect to the cluster, a NoConnectionException is thrown when attempting to perform any remote operation.
If the client unexpectedly loses the connection before or during an operation, an OperationStatusUnknownException is thrown. In this case, it is not known if the operation has been actually executed in the cluster or not. The client will try to reconnect to the next node specified in the configuration when the next operation is called by the application.
Call the disconnect() method to close the connection.
Using Key-Value API
Getting/Creating a Cache Instance
The client instance provides three methods for obtaining an instance of a cache:
getCache(name)— returns an existing cache by name. The method does not verify if the cache exists in the cluster; instead, you will get an exception when attempting to perform any operation with the cache.getOrCreateCache(name, config)— returns an existing cache by name or creates a cache with the given configuration.createCache(name, config)— creates a cache with the given name and parameters.
This is how you can create a cache:
Basic Key-Value Operations
The following code snippet illustrates how to perform basic key-value operations with a cache instance:
Scan Queries
The Cache.query(ScanQuery) method can be used to fetch all entries from the cache. It returns a cursor object with the standard PHP Iterator interface — use this cursor to iterate over the result set lazily, one by one. In addition, the cursor has methods to get all results at once.
Executing SQL Statements
The PHP thin client supports all SQL commands that are supported by GridGain. The commands are executed via the query(SqlFieldQuery) method of the cache object. The method accepts an instance of SqlFieldsQuery that represents a SQL statement. The query() method returns a cursor object with the standard PHP Iterator interface — use this cursor to iterate over the result set lazily, one by one. In addition, the cursor has methods to get all results at once.
Security
SSL/TLS
To use encrypted communication between the thin client and the cluster, you have to enable it both in the cluster configuration and the client configuration. Refer to the Enabling SSL/TLS for Thin Clients section for the instruction on the cluster configuration.
Here is an example configuration for enabling SSL in the thin client:
Authentication
Configure authentication on the cluster side and provide a valid user name and password in the client configuration.
Authorization
For information about authorizing thin client connections, see the Client Authorization page.
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

