PHPackages                             prageeth-peiris/laravel-query-builder-to-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. prageeth-peiris/laravel-query-builder-to-clickhouse

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

prageeth-peiris/laravel-query-builder-to-clickhouse
===================================================

A Simple Package to execute the raw sql query provided by laravel query builder in yandex clickhouse databsae.

1.10(1y ago)13161MITPHPPHP ^8.0

Since May 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/prageeth-peiris/laravel-query-builder-to-clickhouse)[ Packagist](https://packagist.org/packages/prageeth-peiris/laravel-query-builder-to-clickhouse)[ Docs](https://github.com/prageeth-peiris/laravel-query-builder-to-clickhouse)[ RSS](/packages/prageeth-peiris-laravel-query-builder-to-clickhouse/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (7)Dependencies (4)Versions (12)Used By (0)

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

[](#installation)

You can install the package via composer:

```
composer require prageeth-peiris/laravel-query-builder-to-clickhouse
```

Usage
-----

[](#usage)

```
// Usage description here

//Add following database connections to config/database.php

       'bavix::clickhouse' => [
            'driver' => 'bavix::clickhouse',
            'host' => env('CLICKHOUSE_HOST'),
            'port' => env('CLICKHOUSE_PORT',8123),
            'database' => env('CLICKHOUSE_DATABASE'),
            'username' => env('CLICKHOUSE_USER','default'),
            'password' => env('CLICKHOUSE_PASSWORD'),
            'options' => [
                'timeout' => 20,
                'protocol' => 'http'
            ]
        ],
        'clickhouse_custom' => [
            'driver' => 'bavix::clickhouse::custom',
            'host' => env('CLICKHOUSE_HOST'),
            'port' => env('CLICKHOUSE_PORT',8123),
            'database' => env('CLICKHOUSE_DATABASE'),
            'username' => env('CLICKHOUSE_USER','default'),
            'password' => env('CLICKHOUSE_PASSWORD'),
            'options' => [
                'timeout' => 20,
                'protocol' => 'http'
            ]
        ]

//extend from this model and start using clickhouse
use PrageethPeiris\LaravelQueryBuilderToClickhouse\Model;

Class CustomModel extends BaseClickHouseModel {

//this is required if you are doing sub query joining
      protected $tableJoinKey = 'page';

}

//use table with a suffix at runtime
CustomModel::useTableSuffix("in_memory")->insert($data)

//here comes a method to do sub query joining very easily
CustomModel::autoLeftJoinSubQuery(CustomModel::class,OtherModel::GroupBySomething())
->autoLeftJoinSubQuery(CustomModel::class,OtherModel::GroupBySomethingAndSomething())
```

### NOTE

[](#note)

This is an opinionated package so this cache results by raw clickhosue sql query. It will use your default cache driver. to clear cache run `php artisan cache:clear `

### Dependencies

[](#dependencies)

- PHP 8
- Laravel 8
-
-

Read related packages documentation to use their config.

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Prageeth Peiris](https://github.com/prageeth-peiris)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~84 days

Recently: every ~173 days

Total

11

Last Release

667d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfaffa19f7b769d94631a89264b8a89517960ba5f9210af17983cecd8cd6e11a?d=identicon)[prageeth-peiris](/maintainers/prageeth-peiris)

---

Top Contributors

[![prageeth-peiris](https://avatars.githubusercontent.com/u/57320631?v=4)](https://github.com/prageeth-peiris "prageeth-peiris (27 commits)")

---

Tags

prageeth-peirislaravel-query-builder-to-clickhouse

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/prageeth-peiris-laravel-query-builder-to-clickhouse/health.svg)

```
[![Health](https://phpackages.com/badges/prageeth-peiris-laravel-query-builder-to-clickhouse/health.svg)](https://phpackages.com/packages/prageeth-peiris-laravel-query-builder-to-clickhouse)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.9M11.6k](/packages/illuminate-database)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

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

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[lemaur/eloquent-publishing

218.1k1](/packages/lemaur-eloquent-publishing)[laravel-liberu/laravel-gedcom

A package that converts gedcom files to Eloquent models

782.5k1](/packages/laravel-liberu-laravel-gedcom)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
