lexxusss / laravel-clickhouse
The Driver for Laravel Clickhouse ORM.
dev-master
2019-06-16 19:10 UTC
Requires
- php: >=7.1
- esazykin/clickhouse-builder: ^1.1
- laravel/framework: ^5.5
Requires (Dev)
- fzaninotto/faker: ^1.7
- mockery/mockery: ^1.0
- phpunit/phpunit: ^6.5
This package is auto-updated.
Last update: 2026-03-17 11:31:34 UTC
README
Eloquent model for ClickHouse
Prerequisites
- php 7.1
- clickhouse server
Installation
$ composer require lexxusss/laravel-clickhouse
Then add the code above into your config/app.php file providers section
Lexxusss\LaravelClickHouse\ClickHouseServiceProvider::class,
And add new connection into your config/database.php file. Something like this:
'connections' => [
'clickhouse' => [
'driver' => 'clickhouse',
'host' => '',
'port' => '',
'database' => '',
'username' => '',
'password' => '',
'options' => [
'timeout' => 10,
'protocol' => 'https'
]
]
]
Or like this, if clickhouse runs in cluster
'connections' => [
'clickhouse' => [
'driver' => 'clickhouse',
'cluster' => [
'server-1' => [
'host' => '',
'port' => '',
'database' => '',
'username' => '',
'password' => '',
'options' => [
'timeout' => 10,
'protocol' => 'https'
]
],
'server-2' => [
'host' => '',
'port' => '',
'database' => '',
'username' => '',
'password' => '',
'options' => [
'timeout' => 10,
'protocol' => 'https'
]
]
]
]
]
Then create model
<?php
use Lexxusss\LaravelClickHouse\Database\Eloquent\Model;
class Payment extends Model
{
protected $table = 'payments';
}
And use it
Payment::select(raw('count() AS cnt'), 'payment_system')
->whereBetween('payed_at', [
Carbon\Carbon::parse('2017-01-01'),
now(),
])
->groupBy('payment_system')
->get();
Roadmap
- more tests
- Model::with() method
- relations