cboxdk / laravel-billing-clickhouse
Cbox Billing — ClickHouse event-log adapter: a columnar EventLog implementation for event-heavy metering, for cboxdk/laravel-billing.
Package info
github.com/cboxdk/laravel-billing-clickhouse
pkg:composer/cboxdk/laravel-billing-clickhouse
Requires
- php: ^8.4
- cboxdk/laravel-billing: ^0.1
- illuminate/contracts: ^13.0
- illuminate/http: ^13.0
- illuminate/support: ^13.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
README
cboxdk/laravel-billing-clickhouse — a ClickHouse-backed EventLog for
cboxdk/laravel-billing, for
event-heavy, high-cardinality metering where the relational event log would strain.
ClickHouse is optional: small/most deployments use the relational event log that
ships with billing. Install this only when your usage volume calls for a columnar
store — the EventLog contract is identical, so nothing calling it changes.
Install
composer require cboxdk/laravel-billing-clickhouse
// .env CLICKHOUSE_DSN=http://localhost:8123 CLICKHOUSE_USER=default CLICKHOUSE_PASSWORD=
With a DSN set, billing's Cbox\Billing\Metering\Contracts\EventLog is bound to the
ClickHouse adapter. Create the table once:
app(\Cbox\Billing\ClickHouse\ClickHouseEventLog::class)->migrate();
Design
- HTTP interface, no heavy SDK. Talks to ClickHouse over its HTTP endpoint via
the Laravel HTTP client, so the append/sum logic is fully testable with
Http::fake. - Idempotent by table engine. A
ReplacingMergeTreekeyed on the event id collapses duplicates on merge;sumdeduplicates by event id at query time, so it is correct even before a merge runs. Query parameters are bound, not interpolated.
Verify against a live ClickHouse before relying on it in production.
Requirements
PHP ^8.4; Laravel ^12 || ^13; cboxdk/laravel-billing.
License
MIT.