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

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

laravel-clickhouse/laravel-clickhouse
=====================================

A ClickHouse based Eloquent model and Query builder for Laravel

v1.1.2(3w ago)1974.2k↓34.8%6[3 issues](https://github.com/laravel-clickhouse/laravel-clickhouse/issues)[2 PRs](https://github.com/laravel-clickhouse/laravel-clickhouse/pulls)MITPHPPHP ^8.2CI passing

Since Apr 14Pushed 1w ago1 watchersCompare

[ Source](https://github.com/laravel-clickhouse/laravel-clickhouse)[ Packagist](https://packagist.org/packages/laravel-clickhouse/laravel-clickhouse)[ Docs](https://github.com/laravel-clickhouse/laravel-clickhouse)[ Fund](https://www.buymeacoffee.com/sasaya)[ Fund](https://ko-fi.com/sasaya)[ RSS](/packages/laravel-clickhouse-laravel-clickhouse/feed)WikiDiscussions master Synced 1w ago

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

Laravel ClickHouse
==================

[](#laravel-clickhouse)

[![Latest Version on Packagist](https://camo.githubusercontent.com/78ae65b31ea52d5c6499630282af01272025c3e41e372e9e92a07299a0c333ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d636c69636b686f7573652f6c61726176656c2d636c69636b686f7573652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-clickhouse/laravel-clickhouse)[![License](https://camo.githubusercontent.com/e47f95428bf4aeba5d06904beb05d187514b9d1402061ad31f0ea47a73400958/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c61726176656c2d636c69636b686f7573652f6c61726176656c2d636c69636b686f7573652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-clickhouse/laravel-clickhouse)[![PHP Version](https://camo.githubusercontent.com/dfe9a93fffb739ac92b3fc30f36884332befd8f2ec66ccd7bc9f41806218206e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c61726176656c2d636c69636b686f7573652f6c61726176656c2d636c69636b686f7573652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-clickhouse/laravel-clickhouse)

A ClickHouse database driver for Laravel. Provides a familiar Eloquent Model, Query Builder, and Schema Builder with full support for ClickHouse-specific features.

Features
--------

[](#features)

- **Eloquent Model** support with non-incrementing IDs
- **Query Builder** with ClickHouse extensions — ARRAY JOIN, FINAL clause, PREWHERE, SAMPLE, LIMIT BY, GLOBAL IN/NOT IN, ON CLUSTER, CTE (WITH), set operations (UNION/INTERSECT/EXCEPT DISTINCT), ClickHouse-specific joins (ANY, SEMI, ANTI, ASOF), empty/notEmpty checks, SETTINGS clause
- **Schema Builder** with ClickHouse DDL — ENGINE, PARTITION BY, ORDER BY, LowCardinality, Array types, index granularity
- **Lightweight DELETE** with partition targeting
- **Parallel query execution** via Guzzle async HTTP pool
- **Two HTTP transports** — Guzzle (default) and Curl (phpclickhouse)
- **Laravel migrations** with ClickHouse-compatible migration repository
- PHP 8.2+, Laravel 11+

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

[](#installation)

```
composer require laravel-clickhouse/laravel-clickhouse
```

The package uses Laravel's auto-discovery — no manual service provider registration needed.

Add a ClickHouse connection to your `config/database.php`:

```
'connections' => [
    // ...

    'clickhouse' => [
        'driver'   => 'clickhouse',
        'host'     => env('CLICKHOUSE_HOST', '127.0.0.1'),
        'port'     => env('CLICKHOUSE_PORT', 8123),
        'database' => env('CLICKHOUSE_DATABASE', 'default'),
        'username' => env('CLICKHOUSE_USERNAME', 'default'),
        'password' => env('CLICKHOUSE_PASSWORD', ''),
    ],
],
```

For full configuration options, see [Installation &amp; Configuration](docs/docs/installation.md).

Quick Start
-----------

[](#quick-start)

### Query Builder

[](#query-builder)

```
// Basic query with FINAL clause (merges data at query time)
$events = DB::connection('clickhouse')
    ->table('events', final: true)
    ->where('user_id', 1)
    ->get();

// ARRAY JOIN to expand array columns
$results = DB::connection('clickhouse')
    ->table('events')
    ->arrayJoin('tags', 'tag')
    ->where('tag', 'important')
    ->get();

// ClickHouse-specific join
$results = DB::connection('clickhouse')
    ->table('events')
    ->asofJoin('metrics', 'events.timestamp', 'metrics.timestamp')
    ->get();
```

### Eloquent Model

[](#eloquent-model)

```
use ClickHouse\Laravel\Eloquent\Model;

class Event extends Model
{
    protected $connection = 'clickhouse';
    protected $table = 'events';
}

// Query as usual
$events = Event::where('user_id', 1)->get();

// Lightweight delete with partition
Event::where('user_id', 1)->delete(lightweight: true, partition: '202301');
```

### Schema Builder

[](#schema-builder)

```
use ClickHouse\Laravel\Schema\Blueprint as ClickHouseBlueprint;

Schema::connection('clickhouse')->create('events', function (ClickHouseBlueprint $table) {
    $table->unsignedBigInteger('id');
    $table->string('name');
    $table->text('status')->lowCardinality();
    $table->array('tags', 'String');
    $table->dateTime('created_at');

    $table->engine('MergeTree()');
    $table->orderBy(['id', 'created_at']);
    $table->partitionBy('toYYYYMM(created_at)');
});
```

### Parallel Queries

[](#parallel-queries)

```
use ClickHouse\Laravel\Parallel;

$results = Parallel::get([
    'users'  => User::where('active', 1),
    'events' => Event::where('type', 'click'),
]);

// $results['users'] → Collection of User models
// $results['events'] → Collection of Event models
```

Documentation
-------------

[](#documentation)

TopicDescription[Installation &amp; Configuration](docs/docs/installation.md)Requirements, setup, configuration options[Query Builder](docs/docs/query-builder.md)ClickHouse-specific query features[Eloquent Model](docs/docs/eloquent.md)Model definition, CRUD operations[Schema Builder &amp; Migrations](docs/docs/schema.md)Table creation, column types, indexes[Parallel Queries](docs/docs/parallel-queries.md)Concurrent query execution[Advanced Topics](docs/docs/advanced.md)Transports, raw queries, limitationsTesting
-------

[](#testing)

```
composer test
```

Tests require a ClickHouse server running on `127.0.0.1:8123`. See [phpunit.xml.dist](phpunit.xml.dist) for configuration.

```
composer phpstan   # Static analysis
composer cs        # Code style check
composer cs:fix    # Fix code style
```

License
-------

[](#license)

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

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance97

Actively maintained with recent releases

Popularity42

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.7% 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 ~11 days

Total

4

Last Release

22d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6954098?v=4)[Sasaya](/maintainers/storyn26383)[@storyn26383](https://github.com/storyn26383)

---

Top Contributors

[![storyn26383](https://avatars.githubusercontent.com/u/6954098?v=4)](https://github.com/storyn26383 "storyn26383 (96 commits)")[![albertcht](https://avatars.githubusercontent.com/u/9117929?v=4)](https://github.com/albertcht "albertcht (31 commits)")[![stsepelin](https://avatars.githubusercontent.com/u/8102174?v=4)](https://github.com/stsepelin "stsepelin (5 commits)")

---

Tags

phplaraveldatabasemodeleloquentclickhouse

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/laravel-clickhouse-laravel-clickhouse/health.svg)

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M84](/packages/mongodb-laravel-mongodb)[glushkovds/phpclickhouse-laravel

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

2051.4M2](/packages/glushkovds-phpclickhouse-laravel)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

592452.8k2](/packages/spiritix-lada-cache)[gearbox-solutions/eloquent-filemaker

A package for getting FileMaker records as Eloquent models in Laravel

6660.4k2](/packages/gearbox-solutions-eloquent-filemaker)[sebastiaanluca/laravel-boolean-dates

Automatically convert Eloquent model boolean attributes to dates (and back).

40115.4k1](/packages/sebastiaanluca-laravel-boolean-dates)[mvanduijker/laravel-model-exists-rule

Validation rule to check if a model exists

22210.1k2](/packages/mvanduijker-laravel-model-exists-rule)

PHPackages © 2026

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