PHPackages                             simpod/clickhouse-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. simpod/clickhouse-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

simpod/clickhouse-client
========================

PHP ClickHouse Client

0.8.3(1y ago)19116.7k—0.7%3[2 PRs](https://github.com/simPod/PhpClickHouseClient/pulls)MITPHPPHP ^8.2CI passing

Since Mar 12Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/simPod/PhpClickHouseClient)[ Packagist](https://packagist.org/packages/simpod/clickhouse-client)[ Docs](https://github.com/simPod/ClickHouseClient)[ GitHub Sponsors](https://github.com/simPod)[ RSS](/packages/simpod-clickhouse-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (49)Used By (0)

PHP ClickHouse Client
=====================

[](#php-clickhouse-client)

[![Build Status](https://github.com/simPod/PhpClickHouseClient/workflows/CI/badge.svg?branch=master)](https://github.com/simPod/PhpClickHouseClient/actions)[![Code Coverage](https://camo.githubusercontent.com/ecd7089c30dd915b00ba60154d18eb7f9f7a615058bdba9d0cfc252e73cc5ed3/68747470733a2f2f636f6465636f762e696f2f67682f73696d506f642f506870436c69636b486f757365436c69656e742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/simPod/PhpClickHouseClient/branch/master)[![Downloads](https://camo.githubusercontent.com/07e221095db667a566b35ec192c35a5a34e416098d847b4a16e80d178e11c68d/68747470733a2f2f706f7365722e707567782e6f72672f73696d706f642f636c69636b686f7573652d636c69656e742f642f746f74616c2e737667)](https://packagist.org/packages/simpod/clickhouse-client)[![Infection MSI](https://camo.githubusercontent.com/fb68a9a69da831149d17c4e997c9d8b3824b525c623d0cea499f8b1c9f33bc51/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d25324673696d506f64253246506870436c69636b486f757365436c69656e742532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/simPod/PhpClickHouseClient/master)

Motivation
----------

[](#motivation)

The library is trying not to hide any ClickHouse HTTP interface specific details. That said everything is as much transparent as possible and so object-oriented API is provided without inventing own abstractions.
Naming used here is the same as in ClickHouse docs.

- Works with any HTTP Client implementation ([PSR-18 compliant](https://www.php-fig.org/psr/psr-18/))
- All [ClickHouse Formats](https://clickhouse.yandex/docs/en/interfaces/formats/) support
- Logging ([PSR-3 compliant](https://www.php-fig.org/psr/psr-3/))
- SQL Factory for [parameters "binding"](#parameters-binding)
- [Native query parameters](#native-query-parameters) support

Contents
--------

[](#contents)

- [Setup](#setup)
    - [Logging](#logging)
    - [PSR Factories who?](#psr-factories-who)
- [Sync API](#sync-api)
    - [Select](#select)
    - [Select With Params](#select-with-params)
    - [Insert](#insert)
- [Async API](#async-api)
    - [Select](#select-1)
- [Native Query Parameters](#native-query-parameters)
- [Snippets](#snippets)

Setup
-----

[](#setup)

```
composer require simpod/clickhouse-client
```

1. Read about ClickHouse [Http Interface](https://clickhouse.com/docs/en/interfaces/http/). *It's short and useful for concept understanding.*
2. Create a new instance of ClickHouse client and pass PSR factories.
    1. Symfony HttpClient is recommended (performance, less bugs, maintenance)
    2. The plot twist is there's no endpoint/credentials etc. config in this library, provide it via client
3. See tests

```
