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

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

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

Laravel Clickhouse Eloquent

v0.1.4(1y ago)210.1k—1.4%1MITPHP

Since Jun 28Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (9)Versions (4)Used By (0)

Laravel Clickhouse Eloquent
===========================

[](#laravel-clickhouse-eloquent)

Install
-------

[](#install)

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

Add provider to bootstrap/providers.php

```
return [
    //...
    One23\LaravelClickhouse\ClickhouseServiceProvider::class,
    //...
];
```

Add connection to config/database.php

```
return [
    'connections' => [
        //...
        'clickhouse' => [
            'driver' => 'clickhouse',
            'host' => env('CLICKHOUSE_HOST', 'localhost'),
            'port' => env('CLICKHOUSE_PORT', 8123),
            'database' => env('CLICKHOUSE_DATABASE'),
            'username' => env('CLICKHOUSE_USERNAME'),
            'password' => env('CLICKHOUSE_PASSWORD'),
            'options' => [
                'timeout' => 15,
                'protocol' => 'http',
            ],
        ],
        //...
    ]
];
```

Create model. Example:

```
use One23\LaravelClickhouse\Database\Eloquent\Model;

class StatisticDaily extends Model
{
    protected $table = 'mv_statistic_daily';

    protected $casts = [
        'date' => 'date',
        'link_id' => 'int',
        'cnt' => 'int',
        'uniq_ip' => 'int',
    ];

    protected $primaryKey = null;

    //
}
```

Use model. Example:

```
Clickhouse\StatisticDaily::query()
    ->where('date', '=', $dt)
    ->delete();

Clickhouse\StatisticDaily::query()
    ->where('link_id', '=', $OLink->getId())
    ->whereBetween('date', [
        $from->startOfDay()->toDateString(),
        $to->endOfDay()->toDateString(),
    ])
    ->groupBy('date')
    ->selectRaw(implode(', ', [
        '`date`',
        'SUM(`cnt`) AS `cnt`',
        'SUM(`cnt_uniq_ip`) AS `cnt_uniq_ip`',

        'SUM(`cnt_uniq`) AS `cnt_uniq`',
        'SUM(`cnt_mobile`) AS `cnt_mobile`',
        'AVG(`avg_latency`) AS `avg_latency`',
        'MIN(NULLIF(`min_latency`, 0)) AS `min_latency`',
        'MAX(`max_latency`) AS `max_latency`',
        'AVG(`quantile_latency`) AS `quantile_latency`',
    ]))
    ->get();

Clickhouse\StatisticDaily::query()
    ->whereIn('link_id', $linkIds)
    ->whereBetween('date', [
        $this->from
            ->toDateString(),
        $this->to
            ->toDateString(),
    ])
    ->selectRaw(implode(', ', [
        'SUM(`statistic_daily`.`cnt`) as `cnt`',
        'SUM(`statistic_daily`.`cnt_uniq_ip`) as `cnt_uniq_ip`',
    ]))
    ->first();
```

Todo
----

[](#todo)

- Tests
- Deep where's
- Rewrite Grammar
- ...

Security
--------

[](#security)

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

License
-------

[](#license)

[MIT](https://github.com/FlexIDK/language-detection/LICENSE)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance46

Moderate activity, may be stable

Popularity29

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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 ~142 days

Total

3

Last Release

405d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8311e2852f397956d5401ea17683fc8ee583dc68635cdff2fc2f8a5fefb23a98?d=identicon)[FlexIDK](/maintainers/FlexIDK)

---

Top Contributors

[![FlexIDK](https://avatars.githubusercontent.com/u/8653521?v=4)](https://github.com/FlexIDK "FlexIDK (8 commits)")

---

Tags

laraveleloquentclickhouse

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[bavix/laravel-clickhouse

Eloquent model for ClickHouse

72214.1k2](/packages/bavix-laravel-clickhouse)[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)

PHPackages © 2026

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