Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cybercog/laravel-clickhouse
Laravel ClickHouse adds CH client integration, generation & execution of ClickHouse database migrations to the Laravel application.
https://github.com/cybercog/laravel-clickhouse
clickhouse clickhouse-client clickhouse-migration cog database database-schema db db-schema laravel migration php schema
Last synced: 1 day ago
JSON representation
Laravel ClickHouse adds CH client integration, generation & execution of ClickHouse database migrations to the Laravel application.
- Host: GitHub
- URL: https://github.com/cybercog/laravel-clickhouse
- Owner: cybercog
- License: mit
- Created: 2022-03-16T21:19:52.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-12-04T21:03:31.000Z (about 1 month ago)
- Last Synced: 2025-01-07T17:13:52.014Z (8 days ago)
- Topics: clickhouse, clickhouse-client, clickhouse-migration, cog, database, database-schema, db, db-schema, laravel, migration, php, schema
- Language: PHP
- Homepage: https://komarev.com/sources/laravel-clickhouse
- Size: 34.2 KB
- Stars: 87
- Watchers: 2
- Forks: 13
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-clickhouse - cybercog/laravel-clickhouse - Laravel ClickHouse provides ClickHouse database integration and migration capabilities for Laravel applications. (Language bindings / PHP)
README
# Laravel ClickHouse
![laravel-clickhouse](https://user-images.githubusercontent.com/1849174/158847081-af69213c-7f66-40e8-be0b-f127f128c653.png)
## Introduction
Laravel ClickHouse database integration.
This package includes generation and execution of the ClickHouse database migrations in the Laravel application.## Features
- [smi2/phpClickHouse] client integration
- Migration creation
- Migration execution## Installation
Pull in the package through [Composer](https://getcomposer.org/).
```shell
composer require cybercog/laravel-clickhouse
```## Setup
Add environment variables in `.env` file.
```dotenv
CLICKHOUSE_HOST=localhost
CLICKHOUSE_PORT=8123
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=
CLICKHOUSE_DATABASE=default
```### Configuration customization
Publish ClickHouse configuration.
```shell
php artisan vendor:publish --provider="Cog\Laravel\Clickhouse\ClickhouseServiceProvider" --tag=config
```Edit `config/clickhouse.php` file.
## Usage
### ClickHouse client
You can use a singleton object [smi2/phpClickHouse] to query ClickHouse:
```php
app(\ClickHouseDB\Client::class)->select(
/* Query */
);app(\ClickHouseDB\Client::class)->write(
/* Query */
);
```### ClickHouse database migration
#### Create migration
```shell
php artisan make:clickhouse-migration create_example_table
```> New migration will be created in `database/clickhouse-migrations` directory.
#### Run migrations
```shell
php artisan clickhouse:migrate
```To remove the interactive question during production migrations, you can use `--force` option.
```shell
php artisan clickhouse:migrate --force
```##### Step
You can specify how many files need to be applied:
```shell
php artisan clickhouse:migrate --step=1
```> Value `0` is default — all files
#### Rollback migrations
> Rolling back migrations is intentionally unavailable. Migrations should go only forward.
## Changelog
Detailed changes for each release are documented in the [CHANGELOG.md](https://github.com/cybercog/laravel-clickhouse/blob/master/CHANGELOG.md).
## License
- `Laravel ClickHouse` package is open-sourced software licensed under the [MIT license](LICENSE) by [Anton Komarev].
## 🌟 Stargazers over time
[![Stargazers over time](https://chart.yhype.me/github/repository-star/v1/470754925.svg)](https://yhype.me?utm_source=github&utm_medium=cybercog-laravel-clickhouse&utm_content=chart-repository-star-cumulative)
## About CyberCog[CyberCog] is a Social Unity of enthusiasts. Research the best solutions in product & software development is our passion.
- [Follow us on Twitter]
[Anton Komarev]: https://komarev.com
[CyberCog]: https://cybercog.su
[Follow us on Twitter]: https://twitter.com/cybercog
[smi2/phpClickHouse]: https://github.com/smi2/phpClickHouse#start