๐ PHP Client
Welcome to the official ZTeraDB PHP Client documentation. This package implements a high-performance, ZQL-first database driver utilizing a raw TCP socket transport layer.
๐ What Is ZTeraDB?โ
ZTeraDB allows you to connect to your existing databases (PostgreSQL, MySQL, MSSQL, etc.) through a single, unified platform using One Unified Query Language (ZQL).
Technical Overviewโ
This package implements a performance-optimized, ZQL-first PHP client utilizing a raw TCP socket transport layer.
To ensure low-overhead binary framing, the client communicates with the ZTeraDB server using 4-byte big-endian length-prefixed payloads containing structured JSON data. This underlying transport architecture eliminates HTTP overhead, offering high-throughput query execution directly from your PHP runtime.
๐ง Architecture Overviewโ
You never connect to your backend databases directly. ZTeraDB handles all connections, cryptographic signing, proxy routing, and query execution securely behind the scenes.
โญ Key Featuresโ
- ๐ Unified Query Language (ZQL): Write once, run on any database.
- ๐ Easy Integration: Seamlessly plugs into any PHP application.
- โ๏ธ Auto-Managed Connections: Handles connection pooling and automatic retries.
- ๐ Secure Authentication: Protected via client, access, and secret keys.
- ๐ฏ Clean Query Builder: Fluent interface for standard CRUD operations (
insert,select,update,delete). - ๐ Advanced Filtering: Built-in support for complex logical and mathematical filters.
- ๐งต Streamed Results: Efficiently memory-manages large datasets using PHP generators.
- ๐ฆ Modern Ecosystem: Composer-ready and fully compatible with frameworks like Laravel, Symfony, and CodeIgniter.
๐ Prerequisites & Requirementsโ
| Requirement | Specification |
|---|---|
| PHP Version | PHP 7.2 or higher (Download from php.net) |
| Extensions | sockets extension must be enabled in your php.ini file |
| Package Registry | Available via Packagist |
Installationโ
Option 1: Via Composer (Recommended)โ
Run the following command in your terminal to install the ZTeraDB client:
# Using composer
composer require zteradb/zteradb-php
Option 2: From GitHub Repositoryโ
Alternatively, you can pull the package directly from GitHub. Add the repository to your composer.json file:
{
"repositories": [
{
"type": "vcs",
"url": "[https://github.com/zteradb/zteradb-php](https://github.com/zteradb/zteradb-php)"
}
],
"require": {
"zteradb/zteradb-php": "v2.0.0"
}
}
Then, run the installation command:
composer require zteradb/zteradb-php:v2.0.0
๐ 60-Second Quick Start
<?php
require_once "vendor/autoload.php";
use ZTeraDB\Config\ZTeraDBConfig;
use ZTeraDB\Connection\ZTeraDBConnection;
use ZTeraDB\Query\ZTeraDBQuery;
use ZTeraDB\Config\ResponseDataTypes;
use ZTeraDB\Config\ENVS;
// 1. Setup Configuration
$config = new ZTeraDBConfig([
'client_key' => getenv('ZTERADB_CLIENT_KEY'),
'access_key' => getenv('ZTERADB_ACCESS_KEY'),
'secret_key' => getenv('ZTERADB_SECRET_KEY'),
'database_id' => getenv('ZTERADB_DATABASE_ID'),
'env' => ENVS::dev,
'response_data_type' => ResponseDataTypes::json,
]);
// 2. Initialize Connection
$db = new ZTeraDBConnection(
getenv("ZTERADB_HOST"),
getenv("ZTERADB_PORT"),
$config
);
// 3. Build ZQL Query
$query = (new ZTeraDBQuery("user"))->select();
// 4. Execute and Stream Results
foreach ($db->run($query) as $row) {
print_r($row);
}
// 5. Close Connection
$db->close();
?>
๐ Documentation Sectionsโ
Explore the rest of our guides to unlock the full potential of ZTeraDB:
- ๐ Configuration โ Learn all available configuration options.
- ๐ Connection โ Deep dive into socket connections and lifecycle management.
- ๐ Query Builder โ Master building fluent ZQL queries.
- ๐๏ธ Filter Conditions โ Apply advanced math and logical filters to your data.
- ๐ณExamples โ Copy-pasteable snippets for common use cases.
- ๐ Troubleshooting Guide โ How to resolve common connection or runtime errors.
- ๐ Quickstart Guide โ A streamlined, 5-minute setup guide.
- ๐ฅ Licence โ Open-source licence terms.