{"id":50822404,"url":"https://github.com/true-async/php-clickhouse","last_synced_at":"2026-06-13T15:03:05.464Z","repository":{"id":363504085,"uuid":"1261291964","full_name":"true-async/php-clickhouse","owner":"true-async","description":"Native asynchronous ClickHouse client for PHP TrueAsync, built on the official clickhouse-cpp native-protocol library.","archived":false,"fork":false,"pushed_at":"2026-06-09T06:55:42.000Z","size":63,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-09T08:22:41.344Z","etag":null,"topics":["async","clickhouse","php"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/true-async.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-06T13:47:28.000Z","updated_at":"2026-06-09T06:37:37.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/true-async/php-clickhouse","commit_stats":null,"previous_names":["true-async/php-clickhouse"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/true-async/php-clickhouse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/true-async%2Fphp-clickhouse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/true-async%2Fphp-clickhouse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/true-async%2Fphp-clickhouse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/true-async%2Fphp-clickhouse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/true-async","download_url":"https://codeload.github.com/true-async/php-clickhouse/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/true-async%2Fphp-clickhouse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34288666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","clickhouse","php"],"created_at":"2026-06-13T15:03:04.775Z","updated_at":"2026-06-13T15:03:05.458Z","avatar_url":"https://github.com/true-async.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# php-clickhouse\n\n**Native asynchronous ClickHouse client for [PHP TrueAsync](https://github.com/true-async).**\n*Write sync, run async.*\n\n[![CI](https://github.com/true-async/php-clickhouse/actions/workflows/ci.yml/badge.svg)](https://github.com/true-async/php-clickhouse/actions/workflows/ci.yml)\n[![PHP](https://img.shields.io/badge/PHP-8.x_ZTS-777BB4?style=flat-square\u0026logo=php\u0026logoColor=white)](https://www.php.net/)\n[![ClickHouse](https://img.shields.io/badge/ClickHouse-native_protocol-FFCC00?style=flat-square\u0026logo=clickhouse\u0026logoColor=black)](https://clickhouse.com/)\n[![License](https://img.shields.io/badge/license-Apache_2.0-blue?style=flat-square)](LICENSE)\n\n\u003c/div\u003e\n\nBuilt on the official [`ClickHouse/clickhouse-cpp`](https://github.com/ClickHouse/clickhouse-cpp)\nnative-protocol library. Every network call looks synchronous but transparently\nyields the current coroutine while it waits on the socket. One `Client` serves\nmany concurrent coroutines through a hidden per-coroutine connection pool.\n\n```php\nuse TrueAsync\\ClickHouse\\Client;\nuse function Async\\spawn;\nuse function Async\\await_all;\n\n$client = new Client(['host' =\u003e '127.0.0.1', 'user' =\u003e 'default']);\n\n// Two coroutines query at the same time; each transparently borrows its own\n// connection from the hidden pool, so the work overlaps on the wire.\n[$results] = await_all([\n    spawn(fn() =\u003e $client-\u003equery(\"SELECT count() AS c FROM events\")-\u003efetchOne()),\n    spawn(fn() =\u003e $client-\u003equery(\n        \"SELECT name, count() AS c FROM events WHERE day = {d:Date} GROUP BY name\",\n        ['d' =\u003e '2026-06-07']\n    )-\u003efetchAll()),\n]);\n```\n\n## Features\n\n- **Async over the TrueAsync reactor:** non-blocking reads/writes; the\n  coroutine yields instead of blocking the thread.\n- **Native protocol** with **LZ4 / ZSTD** compression.\n- **Hidden per-coroutine pool:** concurrent queries each get their own\n  connection; dead connections are dropped and replaced automatically.\n- **`query()` → `Result`:** buffer with `fetchAll()`, stream with `foreach`\n  (lazy, block by block), or read a scalar with `fetchOne()`; carries server\n  statistics (`summary()`, `affectedRows()`).\n- **`insert()`:** columnar batch insert; **`insertBatch()`:** streaming insert\n  with built-in backpressure.\n- **Native `{name:Type}` parameter binding:** typed and injection-safe.\n- **Rich type mapping:** integers, floats, `Bool`, `String`, `UUID`,\n  `IPv4/IPv6`, `Decimal`, `Enum`, `Date*`/`DateTime*` → `DateTimeImmutable`,\n  `Array`/`Tuple`/`Map`/`Nullable`, `Int128`, `LowCardinality(String)`.\n- **Multi-host failover** and **TLS** (`ssl://`).\n- **Typed exceptions:** `ConnectionException`, `ServerException` (with the\n  server error code), `ProtocolException`; caller mistakes raise `\\ValueError`.\n\n## Requirements\n\n- PHP 8.x built with **ZTS** and the **TrueAsync** runtime.\n- A **C++17** compiler and **CMake** (to build the bundled clickhouse-cpp).\n\n## Install\n\n```sh\ngit clone --recurse-submodules https://github.com/true-async/php-clickhouse.git\ncd php-clickhouse\n# build the bundled clickhouse-cpp, then phpize \u0026\u0026 ./configure \u0026\u0026 make\n```\n\nFull steps: **[docs/installation.md](docs/installation.md)**.\n\n## Documentation\n\n- [Installation](docs/installation.md)\n- [Configuration](docs/configuration.md): connection, auth, compression, pool, failover, TLS\n- [Usage](docs/usage.md): query, the Result object, insert, insertBatch, errors\n- [Type mapping](docs/types.md): ClickHouse ↔ PHP\n- [Connection pool](docs/pool.md)\n- [Architecture](docs/architecture.md): internal design\n\nSee the [`tests/`](tests) directory for runnable examples of every feature.\n\n## License\n\nApache-2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrue-async%2Fphp-clickhouse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrue-async%2Fphp-clickhouse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrue-async%2Fphp-clickhouse/lists"}