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
Phpclickhouse

Phpclickhouse Laravel Package

smi2/phpclickhouse

PHP client for ClickHouse with an easy, fluent API. Supports queries and inserts, result sets, bindings, and connection configuration for fast analytics workflows. Suitable for Laravel and standalone PHP apps needing reliable ClickHouse access.

View on GitHub
Deep Wiki
Context7

php ClickHouse wrapper

Frequently asked questions about Phpclickhouse
Can I use phpClickHouse with Laravel’s Eloquent ORM for ClickHouse data?
phpClickHouse isn’t designed for direct Eloquent integration, but you can use custom accessors/mutators to handle ClickHouse-specific types like DateTime64 or UUID. For complex queries, consider a repository pattern or Laravel’s Query Builder with the package’s native parameter bindings.
How do I configure phpClickHouse as a secondary database connection in Laravel?
Add a `clickhouse` connection in `config/database.php` with the package’s client configuration. Use `DB::connection('clickhouse')` to run queries. Example: `$results = DB::connection('clickhouse')->select('SELECT * FROM analytics');`
Does phpClickHouse support async queries in Laravel?
Yes, phpClickHouse supports async queries natively. For Laravel, offload async operations to Laravel Queues (e.g., `bus:work`) or use ReactPHP for event-driven async workflows. Bulk inserts can also be queued for background processing.
What Laravel versions and PHP versions does phpClickHouse support?
phpClickHouse requires PHP 8.1+. It’s framework-agnostic but works seamlessly with Laravel 9+ (or 8 with minor adjustments). Ensure your Laravel app meets the PHP 8.1+ requirement for full compatibility.
How do I handle ClickHouse’s DateTime64 type in Laravel models?
Use Eloquent accessors/mutators to convert DateTime64 to Carbon instances. For example, add `getDateTime64Attribute()` to your model to format ClickHouse timestamps. Alternatively, use custom casts in Laravel 8+.
Can I use phpClickHouse for real-time analytics dashboards in Laravel?
Absolutely. phpClickHouse’s native parameter bindings and async query support make it ideal for real-time dashboards. Cache frequent queries in Redis and use Laravel’s Query Builder macros to extend ClickHouse-specific syntax.
What are the alternatives to phpClickHouse for Laravel + ClickHouse?
Alternatives include the official ClickHouse DBAL (PHP extension) for lower latency or Laravel-specific packages like `spatie/laravel-clickhouse`. However, phpClickHouse offers a more feature-rich, zero-dependency PHP client with advanced features like bulk inserts and cluster support.
How do I perform bulk inserts from Laravel into ClickHouse using phpClickHouse?
Use the `insert()` method with arrays or streams. Example: `$db->insert('events', $batchData, ['event_time', 'user_id'])` for structured inserts. For large datasets, stream data via generators or CSV files for memory efficiency.
Does phpClickHouse support ClickHouse clusters with failover?
Yes, phpClickHouse includes built-in cluster support with auto-discovery, health checks, and replica routing. Configure multiple hosts in the client options, and the package will handle failover automatically.
How do I monitor query performance in Laravel when using phpClickHouse?
Use Laravel’s built-in query logging or integrate with Prometheus via custom middleware. phpClickHouse provides structured exceptions with query IDs, which can be logged for debugging. For async queries, track job progress in Laravel Horizon.
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.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views