zteradb/zteradb-php

ZTeraDB PHP client (ZQL, raw socket transport) - PHP 5.6+

Installs: 14

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/zteradb/zteradb-php

v1.1.0 2025-11-29 18:42 UTC

This package is not auto-updated.

Last update: 2026-01-10 19:18:19 UTC


README

This is a PHP 5.6+ client library for interacting with ZTeraDB, a platform that allows you to connect to your existing databases and query them using ZTeraDB Query Language (ZQL). The client provides an easy-to-use interface to send queries to ZTeraDB and retrieve results in a standardized format.

This package implements a ZQL-first PHP client for ZTeraDB using a raw TCP socket transport. It assumes the server uses 4-byte big-endian length-prefixed payloads that contain JSON payloads.

Table of Contents

  1. Features
  2. Requirements
  3. Installing
  4. Usage
  5. Configuration
  6. ZTeraDB Connection
  7. Query
  8. Filter Conditions
  9. License

Features

  • Connect to Multiple Databases: Seamlessly interact with your existing databases through ZTeraDB.
  • ZTeraDB Query Language (ZQL): Use a unified query language to query data across different database systems.
  • Easy Integration: Easily integrate ZTeraDB into your Node.js application.
  • Asynchronous Queries: Support for async/await syntax to handle queries and results asynchronously.
  • Error Handling: Comprehensive error handling to help debug and manage database queries.

Requirements

  • This is a php5.6+ module available through the Packagist (packagist.org) registry.
  • Before installing, download and install php. PHP 5.6.40 or higher is required.

Install

Run following command to install the ZTeraDB client for php.

# Using composer
composer require zteradb/zteradb-php

OR

Install from the ZTeraDB github repository. Create a composor.json file with following content.

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/zteradb/zteradb-php"
    }
  ],
  "require": {
    "zteradb/zteradb-php": "v1.0"
  }
}

Install the ZTeraDB Client for php.

composer require zteradb/zteradb-php:v1.0

Usage

require_once "vendor/autoload.php";

use ZTeraDB\Config\Options;
use ZTeraDB\Config\ConnectionPool;
use ZTeraDB\Config\ENVS;
use ZTeraDB\Config\ResponseDataTypes;
use ZTeraDB\Config\ZTeraDBConfig;
use ZTeraDB\Connection\ZTeraDBConnection;
use ZTeraDB\Query\ZTeraDBQuery;

# ZTeraDB host, port details from environment.
$host = getenv("ZTERADB_HOST");
$port = (int) getenv('PORT');

# ZTeraDB configuration details
$zteradb_config = new ZTeraDBConfig([
        "client_key" => getenv("CLIENT_KEY"),
        "access_key" => getenv("ACCESS_KEY"),
        "secret_key" => getenv("SECRET_KEY"),
        "database_id" => getenv("DATABASE_ID"),
        "env" => ENVS::dev,
        "response_data_type" => ResponseDataTypes::json,
    ]);

# Connect to ZTeraDB server
$conn = new ZTeraDBConnection($host, $port, $zteradb_config);

# Schema name to get the result
$query = new ZTeraDBQuery("<your schema name>");

# Run the query
$rows = $conn->run($query);

# Iterate the query result
foreach($rows as $row) {
  print_r($row);
}

# Close all connections
$conn->close();

License

This project is licensed under the ZTeraDB License - see LICENCE file for details.