ZTeraDB Configuration Guide
This guide explains how to configure the ZTeraDB PHP client using the ZTeraDBConfig class.
๐ฏ What is ZTeraDBConfig?
ZTeraDBConfig is a PHP configuration object that contains all authentication details, environment settings, and optional connection settings required to connect your application to ZTeraDB Server.
It is required for every ZTeraDB connection.
๐งฉ Full Structure
$config = new ZTeraDBConfig([
'client_key' => 'string',
'access_key' => 'string',
'secret_key' => 'string',
'database_id' => 'string',
'env' => 'dev | staging | qa | prod',
'response_data_type' => 'json',
'options' => new Options([
'connection_pool' => new ConnectionPool(
min: 0,
max: 0
)
])
]);
๐ Field-by-field Explanation
๐ client_keyโ
- Your unique ZTeraDB account key.
- Get it from: Dashboard โ Security Credentials.
๐ access_keyโ
- Required for authenticating outgoing requests.
- You can generate multiple access keys.
- Only one active access key is allowed at a time.
๐งฉ secret_keyโ
- Secret signature key used to verify request authenticity.
- You will only see it once when creating it.
- Never share it or commit it to Git.
๐ database_idโ
- Unique ID of your ZTeraDB database.
- Example:
"7K3WHGOJKJJEJ3PFJM407QO25F"
๐ envโ
Defines which ZTeraDB environment your database belongs to.
Allowed values:
dev-> Development Environmentstaging-> Staging Environmentqa-> QA Environmentprod-> Production Environment
Usage example:
'env' => ENVS::dev
๐ฆ response_data_typeโ
- Currently supports only
"json":
'response_data_type' => ResponseDataTypes::json
- Future formats may be added later.
โ๏ธ options.connection_poolโ
You can control automatic connection pooling:
| Field | Meaning |
|---|---|
min | Minimum persistent connections ZTeraDB keeps open |
max | Maximum number of allowed connections |
Example:
'options' => new Options([
'connection_pool' => new ConnectionPool(
min: 2,
max: 10
)
])
If not set โ ZTeraDB manages this automatically.
๐งช Complete Example
use ZTeraDB\Config\ZTeraDBConfig;
use ZTeraDB\Config\Options;
use ZTeraDB\Config\ConnectionPool;
use ZTeraDB\Config\ResponseDataTypes;
use ZTeraDB\Config\ENVS;
$config = new ZTeraDBConfig([
'client_key' => '<Your ZTeraDB client key>',
'access_key' => '<Your ZTeraDB access key>',
'secret_key' => '<Your ZTeraDB secret key>',
'database_id' => '<Your ZTeraDB database id>',
'env' => ENVS::dev,
'response_data_type' => ResponseDataTypes::json,
'options' => new Options([
'connection_pool' => new ConnectionPool(min: 1, max: 5)
])
]);
โ ๏ธ Common Mistakes (Read This!)
โ Wrong environment name
โ Use only: "dev", "staging", "qa", "prod"
โ Missing secret key
โ Ensure .env contains all required fields
โ Hard-coding credentials in code
โ Store all keys in .env files only
โ Not enabling connection pooling in high-traffic apps
โ Use appropriate min & max settings
๐ You are ready to create a connection!
Continue to:
๐ zteradb-connection