PHPackages                             romankobrin/phpclickhouse-laravel - 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. romankobrin/phpclickhouse-laravel

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

romankobrin/phpclickhouse-laravel
=================================

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

v1.8.0(4y ago)04MITPHPPHP &gt;=7.1.0

Since Sep 16Pushed 4y agoCompare

[ Source](https://github.com/romankobrin/phpclickhouse-laravel)[ Packagist](https://packagist.org/packages/romankobrin/phpclickhouse-laravel)[ Docs](https://github.com/glushkovds/phpClickHouse-laravel)[ RSS](/packages/romankobrin-phpclickhouse-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (17)Used By (0)

phpClickHouse-laravel
=====================

[](#phpclickhouse-laravel)

Adapter to Laravel of the most popular libraries:

-  - for connections and perform queries
-  - good query builder

Features
--------

[](#features)

No dependency, only Curl (support php &gt;=7.1 )

More:

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

[](#prerequisites)

- php 7.1
- Laravel 7+
- clickhouse server

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

[](#installation)

**1.** Install via composer

```
$ composer require glushkovds/phpclickhouse-laravel
```

**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),
],
```

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.** Add service provider into your config/app.php file providers section:

```
\PhpClickHouseLaravel\ClickhouseServiceProvider::class,
```

Usage
-----

[](#usage)

You can use smi2/phpClickHouse functionality directly:

```
/** @var \ClickHouseDB\Client $db */
$db = DB::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)

[](#or-use-dawnings-of-eloquent-orm-will-be-implemented-completely)

**1.** Add model

```
