Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Clickhouse Php Client

Clickhouse Php Client Laravel Package

the-tinderbox/clickhouse-php-client

PHP 7.1+ ClickHouse HTTP client built on Guzzle. Configure single servers or clusters, pick random or specific hosts, and run queries per-cluster. Supports async SELECT and INSERT from local files via a simple Client/ServerProvider API.

View on GitHub
Deep Wiki
Context7

Clickhouse client over HTTP

Frequently asked questions about Clickhouse Php Client
Can I use this ClickHouse client in Laravel 9+ without PHP 7.1 compatibility issues?
The package requires PHP 7.1, but Laravel 9+ drops support for it. You’ll need to either upgrade to PHP 8+ (recommended) or use polyfills like `ext-pdo_mysql` or `ext-json` if you’re stuck on PHP 7.4. Test thoroughly, as some Guzzle 6/7 features may behave differently in newer PHP versions.
How do I integrate this client into Laravel’s service container for dependency injection?
Manually bind the client to Laravel’s IoC container in a service provider. For example, use `$this->app->singleton(ClickhouseClient::class, fn($app) => new Client((new ServerProvider())->addCluster(...)));` to configure clusters or servers. This ensures the client is reusable across your application.
Does this package support async queries in Laravel queues for background processing?
Yes, you can dispatch async queries to Laravel queues by wrapping the client’s async methods (e.g., `asyncSelect()` or `asyncInsert()`) in a job. Use Laravel’s queue system to process these jobs in the background, improving performance for long-running operations like batch analytics.
How do I handle ClickHouse clusters with failover or load balancing in Laravel?
Configure clusters in the `ServerProvider` and specify a cluster name before executing queries (e.g., `$client->onCluster('analytics')`). The client will randomly select a server from the cluster by default. For failover, ensure your cluster has multiple servers, and handle exceptions gracefully with retries or fallbacks.
Is there a query builder or Eloquent-like abstraction for ClickHouse tables?
No, this package is designed for raw SQL queries over HTTP. If you need a fluent query builder, consider pairing it with a library like `clickhouse-php` or building a custom wrapper. For Eloquent-like functionality, you’d need to extend Laravel’s Eloquent or use a hybrid approach with raw queries.
How do I securely store ClickHouse credentials in Laravel (e.g., username/password)?
Use Laravel’s `.env` file to store credentials (e.g., `CLICKHOUSE_USER=user`, `CLICKHOUSE_PASSWORD=pass`). Access them via `config('services.clickhouse')` or `env('CLICKHOUSE_USER')`. Avoid hardcoding credentials in your code, and consider using Laravel’s `config/caching` or a secrets manager for production.
Can I use this client to bulk insert data from CSV/TSV files into ClickHouse?
Yes, the client supports async `INSERT` operations from local files via the `asyncInsert()` method. This is useful for bulk operations like ETL or analytics pipelines. Ensure the file paths are correct and permissions are set properly to avoid silent failures during inserts.
What alternatives exist for Laravel ClickHouse integration if this package lacks maintenance?
Alternatives include `clickhouse-php` (official PHP client with PDO support), `ruflin/elastica` (if you need Elasticsearch-like abstractions), or `doctrine/dbal` with a custom ClickHouse driver. For Laravel-specific needs, consider building a wrapper around this client or another HTTP-based solution.
How do I monitor query performance or errors in production with this client?
Log query execution details (e.g., duration, rows affected) using Laravel’s logging system. For errors, wrap client calls in try-catch blocks and log exceptions. ClickHouse’s HTTP interface returns metadata like `rowsBeforeLimitAtLeast`—parse these in your application logic for monitoring.
Will this package work with Laravel’s HTTP client (Guzzle) or do I need to install Guzzle separately?
The package uses Guzzle internally, but it won’t conflict with Laravel’s HTTP client if you configure it properly. You can either rely on the package’s bundled Guzzle or align Laravel’s Guzzle version (v6/7) in `composer.json` to avoid version mismatches. No separate Guzzle install is required unless you customize the client.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime