bkmz48 / laravel-clickhouse
Eloquent model for ClickHouse
dev-master
2022-08-17 09:01 UTC
Requires
- php: ^7.2|^8.0
- ext-json: *
- laravel/framework: ^6.0|^7.0|^8.0|^9.0
- the-tinderbox/clickhouse-builder: ^4.0
Requires (Dev)
- bavix/clickhouse-builder: ^4.0
- bavix/clickhouse-php-client: ^3.0
- fakerphp/faker: ^1.9
- infection/infection: ~0.15
- mockery/mockery: ^1.3
- phpunit/phpunit: ^8.0|^9.0
This package is auto-updated.
Last update: 2025-02-17 13:58:29 UTC
README
Laravel Clickhouse - Eloquent model for ClickHouse.
- Vendor: bavix
- Package: Laravel Clickhouse
- Version:
- Laravel Version:
6.x
,7.x
,8.x
- PHP Version: 7.2+
- Composer:
composer require bavix/laravel-clickhouse
⚠️ If you are using php 8 and
the-tinderbox/clickhouse-*
author hasn't added support yet, then connect mine.composer req bavix/clickhouse-php-client
composer req bavix/clickhouse-builder
Get started
$ composer require bavix/laravel-clickhouse
Then add the code above into your config/app.php file providers section
Bavix\LaravelClickHouse\ClickHouseServiceProvider::class,
And add new connection into your config/database.php file. Something like this:
'connections' => [ 'bavix::clickhouse' => [ 'driver' => 'bavix::clickhouse', 'host' => '', 'port' => '', 'database' => '', 'username' => '', 'password' => '', 'options' => [ 'timeout' => 10, 'protocol' => 'https' ] ] ]
Or like this, if clickhouse runs in cluster
'connections' => [ 'bavix::clickhouse' => [ 'driver' => 'bavix::clickhouse', 'servers' => [ [ 'host' => 'ch-00.domain.com', 'port' => '', 'database' => '', 'username' => '', 'password' => '', 'options' => [ 'timeout' => 10, 'protocol' => 'https' ] ], [ 'host' => 'ch-01.domain.com', 'port' => '', 'database' => '', 'username' => '', 'password' => '', 'options' => [ 'timeout' => 10, 'protocol' => 'https' ] ] ] ] ],
Then create model
<?php use Bavix\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();
Supported by