churakovmike/laravel-clickhouse

Eloquent extension with Clickhouse

v0.4 2021-10-10 14:34 UTC

This package is auto-updated.

Last update: 2024-11-21 22:40:49 UTC


README

Maintainability License Latest Stable Version PHP Version Require StyleCI PSALM

Requirements

  • laravel 7+
  • php 7.4+

Install

composer require churakovmike/laravel-clickhouse

If you need the latest version

composer require churakovmike/laravel-clickhouse:dev-main

Integrations

In config/app.php add:

    'providers' => [
        ...
        \ChurakovMike\LaravelClickHouse\ClickhouseServiceProvider::class,
        ...
    ]

Connection configures via config/database.php

Clickhouse default configuration example:

'connections' => [
    'clickhouse' => [
        'driver' => 'clickhouse',
        'host' => 'http://127.0.0.1',
        'port' => 8123,
        'database' => 'database_name',
        'username' => 'default',
        'password' => '',
        'options' => [
            'timeout' => 10,
        ]
    ]
]

Usage

Create new own model and inherit from the new model

<?php

namespace App;

use ChurakovMike\LaravelClickHouse\Database\Model;

class Events extends Model
{
    // ...
}

That's all, you can work with clickhouse using the familiar Eloquent model.

Following features coming soon

  • Clusters switching
  • Server switching
  • Native clickhouse functions for the model (sumIf, countIf, quantilesTimingIf, argMinIf and etc.)
  • New migration manager and new Blueprint for Clickhouse
  • New data types for queries