PHPackages                             xtwoend/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. xtwoend/hyperf-clickhouse

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

xtwoend/hyperf-clickhouse
=========================

Clickhouse db for hyperf

9428↓100%7PHP

Since May 22Pushed 3y ago1 watchersCompare

[ Source](https://github.com/xtwoend/hyperf-clickhouse)[ Packagist](https://packagist.org/packages/xtwoend/hyperf-clickhouse)[ RSS](/packages/xtwoend-hyperf-clickhouse/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)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 7.1
- Hyperf PHP
- Clickhouse server

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

[](#installation)

1. Install via composer

```
$ composer require xtwoend/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',''),
    'timeout_connect' => env('CLICKHOUSE_TIMEOUT_CONNECT',2),
    'timeout_query' => env('CLICKHOUSE_TIMEOUT_QUERY',2),
    'https' => (bool)env('CLICKHOUSE_HTTPS', null),
    'retries' => env('CLICKHOUSE_RETRIES', 0),
    'settings' => [ // optional
        'max_partitions_per_insert_block' => 300,
    ],
],
```

Then patch your .env:

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

3. Used

You can use smi2/phpClickHouse functionality directly:

```
/** @var \ClickHouseDB\Client $db */
$db = Clickhouse::connection('clickhouse')->getClient();
$statement = $db->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

```
