Download the PHP package akbarali1/laravel-clickhouse-eloquent without Composer
On this page you can find all versions of the php package akbarali1/laravel-clickhouse-eloquent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download akbarali1/laravel-clickhouse-eloquent
More information about akbarali1/laravel-clickhouse-eloquent
Files in akbarali1/laravel-clickhouse-eloquent
Package laravel-clickhouse-eloquent
Short Description Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel
License MIT
Homepage https://github.com/akbarali1/laravel-clickhouse-eloquent
Informations about the package laravel-clickhouse-eloquent
phpClickHouse-laravel
Adapter to Laravel and Lumen of the most popular libraries:
- https://github.com/smi2/phpClickHouse - for connections and perform queries
- https://github.com/the-tinderbox/ClickhouseBuilder - good query builder
Features
No dependency, only Curl (support php >=7.1 )
More: https://github.com/smi2/phpClickHouse#features
Prerequisites
- PHP 7.1, 8.0
- Laravel/Lumen 7+
- Clickhouse server
Installation
1. Install via composer
2. Add new connection into your config/database.php:
Then patch your .env:
3. Add service provider into your config/app.php file providers section:
It should be placed before App\Providers\AppServiceProvider::class, and App\Providers\EventServiceProvider::class.
Usage
You can use smi2/phpClickHouse functionality directly:
More about $db
see here: https://github.com/smi2/phpClickHouse/blob/master/README.md
Or use dawnings of Eloquent ORM (will be implemented completely)
1. Add model
Or the second example (But it is not recommended to do so)
2. Add migration
3. And then you can insert data
One row
Or bulk insert
4. Now check out the query builder
Advanced usage
Columns casting
Before insertion, the column will be converted to the required data type specified in the field $casts
.
This feature does not apply to data selection.
The supported cast types are: boolean
.
Events
Events work just like an eloquent model events
Available events: creating, created, saved
Retries
You may enable ability to retry requests while received not 200 response, maybe due network connectivity problems.
Patch your .env:
retries is optional, default value is 0.
0 mean only one attempt.
1 mean one attempt + 1 retry while error (total 2 attempts).
Working with huge rows
You can chunk results like in Laravel
Buffer engine for insert queries
See https://clickhouse.tech/docs/en/engines/table-engines/special/buffer/
If you also want to read from your buffer table, put its name in $table
OPTIMIZE Statement
See https://clickhouse.com/docs/ru/sql-reference/statements/optimize/
TRUNCATE Statement
Removes all data from a table.
Deletions
See https://clickhouse.com/docs/en/sql-reference/statements/alter/delete/
Using buffer engine and performing OPTIMIZE or ALTER TABLE DELETE
Updates
See https://clickhouse.com/docs/ru/sql-reference/statements/alter/update/
Helpers for inserting different data types
Working with multiple Clickhouse instances in a project
1. Add second connection into your config/database.php:
2. Add model
3. Add migration
All versions of laravel-clickhouse-eloquent with dependencies
smi2/phpclickhouse Version ^1.4.2
the-tinderbox/clickhouse-builder Version ^6.0
illuminate/support Version >=7
illuminate/database Version >=7