Download the PHP package ysfkc/clickhouse without Composer
On this page you can find all versions of the php package ysfkc/clickhouse. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ysfkc/clickhouse
More information about ysfkc/clickhouse
Files in ysfkc/clickhouse
Package clickhouse
Short Description Lightweight ClickHouse HTTP client with a fluent QueryBuilder and ORM-style base model for PHP 8.1+.
License MIT
Informations about the package clickhouse
ysfkc/clickhouse
A lightweight, framework-agnostic ClickHouse HTTP client for PHP 8.1+ with a fluent QueryBuilder and an ORM-style model layer.
Table of Contents
- Architecture
- Installation
- Configuration
- Step 1 — Configure
- Step 2 — getInstance()
- Step 3 — Usage
- QueryBuilder
- SELECT
- WHERE Conditions
- JOIN
- GROUP BY / HAVING
- ORDER BY / LIMIT / OFFSET
- INSERT
- Raw Query — raw()
- Model System (ORM)
- Defining a Model
- Querying Records
- Inserting Records
- rawQuery / rawCommand
- ClickHouseResponse
- ClickHouseCollection
- Direct Client Usage
- Security
- ClickHouse Type Reference
- Phalcon Integration
Architecture
Installation
Requirements: PHP 8.1+, guzzlehttp/guzzle ^7.0, psr/log ^1|^2|^3
Configuration
Step 1 — Configure once at bootstrap
Call ClickHouseClientService::configure() once at application startup (service provider, bootstrap file, etc.):
With a PSR-3 logger:
Step 2 — Obtain the client via getInstance()
After configure() is called, retrieve the shared ClickHouseClient instance from anywhere in your application:
getInstance() creates the client lazily on the first call and returns the same instance on every subsequent call. Calling configure() again invalidates the old instance and forces a fresh one on the next getInstance() call.
⚠️ Calling
getInstance()beforeconfigure()throws a\RuntimeException.
Step 3 — Use the client directly or via QueryBuilder / Model
Once configured, you can use any of the three layers — they all resolve the client internally via getInstance():
Optional — Inject a PSR-3 logger for models
QueryBuilder
QueryBuilder is started via the static table() method. All methods support fluent chaining.
SELECT
WHERE Conditions
Basic Equality
Comparison Operators
IN / NOT IN
BETWEEN (Date Range)
NULL Checks
whereRaw — Raw Condition
⚠️ Use only when
where()cannot express the condition. Never embed user input directly — useQueryBuilder::raw()with parameters instead.
JOIN
GROUP BY / HAVING
ORDER BY / LIMIT / OFFSET
First Row
COUNT
INSERT
Single Row
Batch INSERT
Raw Query — raw()
For complex queries that cannot be expressed with the structured methods:
Debug — toSql()
Model System (ORM)
Defining a Model
Querying Records
all() — All Records
find() — Conditional Query
findFirst() — First Record
countBy() — Count
query() — Advanced Fluent Query
queryBetweenDates() — Date Range Shorthand
Inserting Records
insertRow() — Single Row
insertBatch() — Bulk Insert
rawQuery / rawCommand
rawQuery — Custom SELECT
⚠️ Pass only hardcoded strings as
$query. All dynamic values must go through$params.
rawCommand — DDL Commands
ClickHouseResponse
ClickHouseCollection
Direct Client Usage
Security
Parameterized Queries
All user-supplied values are sent as param_* query string parameters, never interpolated into the SQL body:
Blocked Vectors
| Category | Examples |
|---|---|
| Statement chaining | ; separator |
| DDL | DROP, ALTER, CREATE, TRUNCATE |
| DML (external) | INSERT INTO, DELETE FROM |
| SSRF | url(), remote(), s3(), hdfs() |
| LFI | file() |
| Schema discovery | SHOW TABLES, DESCRIBE |
| Exfiltration | INTO OUTFILE, clusterAllReplicas(), dictGet() |
| Time-based | sleep(), benchmark() |
| Subquery (whereRaw/having/join) | (SELECT …) |
Rule: whereRaw / having / join Conditions
ClickHouse Type Reference
| Type | Description | Example |
|---|---|---|
String |
UTF-8 text | 'click' |
Int8 / Int16 / Int32 / Int64 |
Signed integer | 123 |
UInt8 / UInt16 / UInt32 / UInt64 |
Unsigned integer | 456 |
Float32 / Float64 |
Floating-point | 3.14 |
Date |
Date YYYY-MM-DD |
'2026-04-06' |
DateTime |
Datetime YYYY-MM-DD HH:MM:SS |
'2026-04-06 12:00:00' |
DateTime64(3) |
Millisecond-precision datetime | '2026-04-06 12:00:00.123' |
Nullable(Int32) |
Nullable Int32 | null or 123 |
Array(String) |
String array — for IN |
['a', 'b'] |
Array(Int32) |
Int32 array — for IN |
[1, 2, 3] |
LowCardinality(String) |
Low-cardinality string | 'ok' |
Note: The
Array(…)wrapper is added automatically forIN/NOT IN.->where('status', 'IN', ['ok', 'warning', 'error'], 'String')→status IN {p:Array(String)}
Phalcon Integration (Optional)
If you use this package inside a Phalcon application, bridge the Phalcon logger to PSR-3 using the included optional adapter:
License
MIT
All versions of clickhouse with dependencies
guzzlehttp/guzzle Version ^6.0.0|^7.4.5
psr/log Version ^1.0 || ^2.0 || ^3.0