biblioonline/laravel-clickhouse
2,276
| Install | |
|---|---|
composer require biblioonline/laravel-clickhouse |
|
| Latest Version: | v0.2 |
| PHP: | >=7.1 |
| License: | MIT |
| Last Updated: | May 27, 2020 |
| Links: | GitHub · Packagist |
Maintainer: biblioonline
laravel-clickhouse
Eloquent model for ClickHouse
Prerequisites
- php 7.1
- laravel 5.1
- clickhouse server
Installation
$ composer require biblioonline/laravel-clickhouse
Then add the code above into your config/app.php file providers section
BiblioOnline\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 BiblioOnline\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
Related Packages
laravel-clickhouse/laravel-clickhouse
A ClickHouse based Eloquent model and Query builder for Laravel
66,129
229