PHPackages                             tangwei/hyperf-clickhouse - 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. [Database &amp; ORM](/categories/database)
4. /
5. tangwei/hyperf-clickhouse

ActiveLibrary[Database &amp; ORM](/categories/database)

tangwei/hyperf-clickhouse
=========================

Clickhouse db for hyperf

v1.0.1(1y ago)15.2k↓42.5%MITPHPPHP ^8.1

Since Jul 4Pushed 1y agoCompare

[ Source](https://github.com/tw2066/hyperf-clickhouse)[ Packagist](https://packagist.org/packages/tangwei/hyperf-clickhouse)[ RSS](/packages/tangwei-hyperf-clickhouse/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (8)Versions (7)Used By (0)

phpClickHouse-hyperf
====================

[](#phpclickhouse-hyperf)

Adapter to Hyperf framework of the most popular libraries:

-  - good query builder

Features
--------

[](#features)

No dependency

More:

Prerequisites
-------------

[](#prerequisites)

- PHP 8.1
- Hyperf = 3.1
- Clickhouse server

Installation
------------

[](#installation)

1. Install via composer

```
$ composer require tangwei/hyperf-clickhouse
```

2. Add new connection into your config/database.php:

```
    'clickhouse' => [
        'driver' => 'clickhouse',
        'host' => env('CLICKHOUSE_HOST'),
        'port' => env('CLICKHOUSE_PORT','8123'),
        'database' => env('CLICKHOUSE_DATABASE','default'),
        'username' => env('CLICKHOUSE_USERNAME','default'),
        'password' => env('CLICKHOUSE_PASSWORD',''),
        'https' => (bool)env('CLICKHOUSE_HTTPS',false),
        'settings' => [ // optional
            // 'max_partitions_per_insert_block' => 300,
        ],
        'pool' => [
            'min_connections' => 1,
            'max_connections' => 3,
            'connect_timeout' => 10.0,
            'wait_timeout'    => 3.0,
            'heartbeat'       => -1,
            'max_idle_time'   => 60,
        ],
    ],
```

Then patch your .env:

```
CLICKHOUSE_HOST=localhost
CLICKHOUSE_PORT=8123
CLICKHOUSE_DATABASE=default
CLICKHOUSE_USERNAME=default
CLICKHOUSE_PASSWORD=
# only if you use https connection
CLICKHOUSE_HTTPS=true
```

3. Used

You can use smi2/phpClickHouse functionality directly:

```
$client = \Tang\HyperfClickhouse\DB::query()->getClient();
$statement = $client->select('SELECT * FROM summing_url_views LIMIT 2');
```

More about $db see here:

Or use dawnings of Eloquent ORM (will be implemented completely)

1. Add model

```
