PHPackages                             cybercog/laravel-clickhouse - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. cybercog/laravel-clickhouse

ActiveLibrary[Database &amp; ORM](/categories/database)

cybercog/laravel-clickhouse
===========================

ClickHouse migrations for Laravel

0.2.1(4mo ago)166251.3k↓21.3%16[6 issues](https://github.com/cybercog/laravel-clickhouse/issues)[2 PRs](https://github.com/cybercog/laravel-clickhouse/pulls)1MITPHPPHP ^8.2CI passing

Since Feb 22Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/cybercog/laravel-clickhouse)[ Packagist](https://packagist.org/packages/cybercog/laravel-clickhouse)[ Docs](https://komarev.com/sources/laravel-clickhouse)[ Fund](https://paypal.me/antonkomarev)[ RSS](/packages/cybercog-laravel-clickhouse/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (14)Versions (10)Used By (1)

Laravel ClickHouse
==================

[](#laravel-clickhouse)

[![laravel-clickhouse](https://user-images.githubusercontent.com/1849174/158847081-af69213c-7f66-40e8-be0b-f127f128c653.png)](https://user-images.githubusercontent.com/1849174/158847081-af69213c-7f66-40e8-be0b-f127f128c653.png)

[![Discord](https://camo.githubusercontent.com/86e83e2f2ffe2f5caffed9d8886bb512bf42bf927dd8bb8e864d9e9983313ff7/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6f676f3d646973636f7264266c6162656c3d266d6573736167653d446973636f726426636f6c6f723d333633393366267374796c653d666c61742d737175617265)](https://discord.gg/YcZDjNTzSa)[![Releases](https://camo.githubusercontent.com/56e9ce4f3be51766b179c32093124b194fbce2962b37c6fdaf96af197f45e897/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6379626572636f672f6c61726176656c2d636c69636b686f7573652e7376673f7374796c653d666c61742d737175617265)](https://github.com/cybercog/laravel-clickhouse/releases)[![License](https://camo.githubusercontent.com/5e89d7b7fcb146450df0c492d66bafaaea0ca2696ce2d82a93f3f2bdd29d5caf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6379626572636f672f6c61726176656c2d636c69636b686f7573652e7376673f7374796c653d666c61742d737175617265)](https://github.com/cybercog/laravel-clickhouse/blob/master/LICENSE)

Introduction
------------

[](#introduction)

Laravel ClickHouse database integration. This package includes generation and execution of the ClickHouse database migrations in the Laravel application.

Features
--------

[](#features)

- [smi2/phpClickHouse](https://github.com/smi2/phpClickHouse#start) client integration
- Migration creation
- Migration execution

Installation
------------

[](#installation)

Pull in the package through [Composer](https://getcomposer.org/).

```
composer require cybercog/laravel-clickhouse
```

Setup
-----

[](#setup)

Add environment variables in `.env` file.

```
CLICKHOUSE_HOST=localhost
CLICKHOUSE_PORT=8123
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=
CLICKHOUSE_DATABASE=default
```

### Configuration customization

[](#configuration-customization)

Publish ClickHouse configuration.

```
php artisan vendor:publish --provider="Cog\Laravel\Clickhouse\ClickhouseServiceProvider" --tag=config
```

Edit `config/clickhouse.php` file.

Usage
-----

[](#usage)

### ClickHouse client

[](#clickhouse-client)

You can use a singleton object [smi2/phpClickHouse](https://github.com/smi2/phpClickHouse#start) to query ClickHouse:

```
app(\ClickHouseDB\Client::class)->select(
    /* Query */
);

app(\ClickHouseDB\Client::class)->write(
    /* Query */
);
```

### ClickHouse database migration

[](#clickhouse-database-migration)

#### Create migration

[](#create-migration)

```
php artisan make:clickhouse-migration create_example_table
```

> New migration will be created in `database/clickhouse-migrations` directory.

#### Run migrations

[](#run-migrations)

```
php artisan clickhouse:migrate
```

To remove the interactive question during production migrations, you can use `--force` option.

```
php artisan clickhouse:migrate --force
```

##### Step

[](#step)

You can specify how many files need to be applied:

```
php artisan clickhouse:migrate --step=1
```

> Value `0` is default — all files

#### Rollback migrations

[](#rollback-migrations)

> Rolling back migrations is intentionally unavailable. Migrations should go only forward.

Changelog
---------

[](#changelog)

Detailed changes for each release are documented in the [CHANGELOG.md](https://github.com/cybercog/laravel-clickhouse/blob/master/CHANGELOG.md).

License
-------

[](#license)

- `Laravel ClickHouse` package is open-sourced software licensed under the [MIT license](LICENSE) by [Anton Komarev](https://komarev.com).

🌟 Stargazers over time
----------------------

[](#-stargazers-over-time)

[![Stargazers over time](https://camo.githubusercontent.com/698f3a547584f07808f6a9e49f488589a8fa66ff9cb71b7b9adbb7a5c825a295/68747470733a2f2f63686172742e79687970652e6d652f6769746875622f7265706f7369746f72792d737461722f76312f3437303735343932352e737667)](https://yhype.me?utm_source=github&utm_medium=cybercog-laravel-clickhouse&utm_content=chart-repository-star-cumulative)

About CyberCog
--------------

[](#about-cybercog)

[CyberCog](https://cybercog.su) is a Social Unity of enthusiasts. Research the best solutions in product &amp; software development is our passion.

- [Follow us on Twitter](https://twitter.com/cybercog)

[![CyberCog](https://cloud.githubusercontent.com/assets/1849174/18418932/e9edb390-7860-11e6-8a43-aa3fad524664.png)](https://cybercog.su)

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance76

Regular maintenance activity

Popularity53

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~185 days

Total

3

Last Release

126d ago

PHP version history (2 changes)0.1.0PHP ^7.4|^8.0

0.2.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3fddc40462126bbc119e373ed6a3f942a90a400f30c076c447c0625b841c4ef?d=identicon)[antonkomarev](/maintainers/antonkomarev)

---

Top Contributors

[![antonkomarev](https://avatars.githubusercontent.com/u/1849174?v=4)](https://github.com/antonkomarev "antonkomarev (29 commits)")[![NelinD](https://avatars.githubusercontent.com/u/10078264?v=4)](https://github.com/NelinD "NelinD (1 commits)")

---

Tags

clickhouseclickhouse-clientclickhouse-migrationcogdatabasedatabase-schemadbdb-schemalaravelmigrationphpschemalaravelmigrationdatabasedbclickhousecogcybercog

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cybercog-laravel-clickhouse/health.svg)

```
[![Health](https://phpackages.com/badges/cybercog-laravel-clickhouse/health.svg)](https://phpackages.com/packages/cybercog-laravel-clickhouse)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M203](/packages/laravel-ai)[spatie/laravel-backup

A Laravel package to backup your application

6.0k24.4M245](/packages/spatie-laravel-backup)[laravel/sail

Docker files for running a basic Laravel application.

1.9k205.7M1.3k](/packages/laravel-sail)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[illuminate/database

The Illuminate Database package.

2.8k54.9M11.7k](/packages/illuminate-database)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
