Quill
PHP

Server SDKs

PHP

quill/quill-php.

Copies the Quill CLI's install command: curl -fsSL https://quill.co/install.sh | shView as MarkdownThe whole page, as plain Markdown.
composer require quill/quill-php
<?php
require __DIR__ . '/vendor/autoload.php';

use Quill\Quill;

$quill = new Quill(getenv('QUILL_PRIVATE_KEY'), 'postgresql', getenv('POSTGRES_READ'));

// POST /quill; $user is the signed-in user, from your own auth
$body = json_decode(file_get_contents('php://input'), true);
$result = $quill->query([
    'tenants' => [['tenantField' => 'organization_id', 'tenantIds' => [$user['org_id']]]],
    'metadata' => $body['metadata'],
]);

header('Content-Type: application/json');
echo json_encode($result);

new Quill

new Quill(string $privateKey, string $databaseType, ?string $databaseConnectionString = null, ?array $databaseConfig = null, ?string $metadataServerURL = null, ?array $cache = null)
Param Default
$privateKey required the private key of your Quill environment
$databaseType required 'postgresql', 'redshift', 'snowflake', 'bigquery', 'mysql', 'clickhouse', 'mssql' or 'databricks'
$databaseConnectionString null the connection string
$databaseConfig null the connection as an array, by $databaseType; used over $databaseConnectionString
$metadataServerURL https://api.quill.co
$cache null ['cacheType' => 'redis' | 'rediss', 'host', 'port', 'username', 'password', 'ttl']: caches results in Redis for ttl seconds, 86400 by default

query

$quill->query(array $params): array
Key Default
'tenants' required [['tenantField' => string, 'tenantIds' => array]], or tenant ids
'metadata' required $body['metadata']
'flags' string[], or [['tenantField' => string, 'flags' => string[]]]
'filters' Quill\Models\Filter[]
'adminEnabled' false allows admin tasks, such as editing dashboards; set it from your own authorization
Returns
'status' 'success' or 'error'
'data' array
'queries' ['queryResults' => array]
'error' string, with 'status' => 'error'

generateClientToken

$quill->generateClientToken(string $publicKey, array $tenants, int $expiration, ?array $flags = null): string
Param
$publicKey
$tenants [['tenantField' => string, 'tenantIds' => array]]
$expiration milliseconds since the epoch, in the future
$flags string[], or [['tenantField' => string, 'flags' => string[]]]