{"id":14966854,"url":"https://github.com/bashkarev/clickhouse","last_synced_at":"2025-10-25T17:30:52.767Z","repository":{"id":47011219,"uuid":"88612454","full_name":"bashkarev/clickhouse","owner":"bashkarev","description":"Extension ClickHouse for Yii 2","archived":false,"fork":false,"pushed_at":"2022-09-26T06:42:37.000Z","size":194,"stargazers_count":22,"open_issues_count":4,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-01T00:23:39.688Z","etag":null,"topics":["clickhouse","php","yii2","yii2-extension"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bashkarev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-18T10:27:16.000Z","updated_at":"2024-02-05T05:40:21.000Z","dependencies_parsed_at":"2022-08-31T05:11:05.040Z","dependency_job_id":null,"html_url":"https://github.com/bashkarev/clickhouse","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashkarev%2Fclickhouse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashkarev%2Fclickhouse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashkarev%2Fclickhouse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashkarev%2Fclickhouse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bashkarev","download_url":"https://codeload.github.com/bashkarev/clickhouse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219865216,"owners_count":16555929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clickhouse","php","yii2","yii2-extension"],"created_at":"2024-09-24T13:37:02.993Z","updated_at":"2025-10-25T17:30:52.376Z","avatar_url":"https://github.com/bashkarev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Extension ClickHouse for Yii 2\n==============================\n\nThis extension provides the [ClickHouse](https://clickhouse.yandex/) integration for the [Yii framework 2.0](http://www.yiiframework.com).\nMain features:\n- SQL commands\n- Query builder\n- Schema builder\n- Migrations\n- Batch Insert\n- Parallel insert from large CSV files\n- Valid handling of UInt64 type in PHP\n- Supports Decimals and Nullable fields\n\n[![Build Status](https://travis-ci.org/bashkarev/clickhouse.svg?branch=master)](https://travis-ci.org/bashkarev/clickhouse)\n\nInstallation\n------------\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\ncomposer require bashkarev/clickhouse\n```\n\n\nConfiguration\n-------------\n\nTo use this extension, simply add the following code in your application configuration:\n\n```php\nreturn [\n    //....\n    'clickhouse' =\u003e [\n        'class' =\u003e 'bashkarev\\clickhouse\\Connection',\n        'dsn' =\u003e 'host=localhost;port=8123;database=default;connect_timeout_with_failover_ms=10',\n        'username' =\u003e 'default',\n        'password' =\u003e '',\n    ],\n];\n```\n\n[All settings](https://clickhouse.yandex/docs/en/operations/settings/index.html)\n\n\nUsing DebugPanel\n----------------\n\nAdd the following to you application config to enable it (if you already have the debug module\nenabled, it is sufficient to just add the panels configuration):\n\n```php\n    // ...\n    'bootstrap' =\u003e ['debug'],\n    'modules' =\u003e [\n        'debug' =\u003e [\n            'class' =\u003e 'yii\\\\debug\\\\Module',\n            'panels' =\u003e [\n                'clickhouse' =\u003e [\n                    'class' =\u003e 'bashkarev\\clickhouse\\debug\\Panel',\n                    // 'db' =\u003e 'clickhouse', // ClickHouse component ID, defaults to `db`. Uncomment and change this line, if you registered component with a different ID.\n                ],\n            ],\n        ],\n    ],\n    // ...\n```\n\nUsing Migrations\n----------------\n\nIn order to enable this command you should adjust the configuration of your console application:\n\n```php\nreturn [\n    // ...\n    'controllerMap' =\u003e [\n        'clickhouse-migrate' =\u003e 'bashkarev\\clickhouse\\console\\controllers\\MigrateController'\n    ],\n];\n```\n\n```bash\n# creates a new migration named 'create_target'\nyii clickhouse-migrate/create create_target\n\n# applies ALL new migrations\nyii clickhouse-migrate\n\n# reverts the last applied migration\nyii clickhouse-migrate/down\n```\nAccess to native SMI2 ClickHouse client\n---------------------------------------\n```php\n$client = \\Yii::$app-\u003eclickhouse-\u003egetClient();\n```\n\nInsert csv files\n----------------\n\n\u003e Files are uploaded in parallel.\n\n```php\n$db = \\Yii::$app-\u003eclickhouse;\n$client = $db-\u003egetClient();\n\n$results = $client-\u003einsertBatchFiles('table_name', ['file_with_data.csv']);\n\n$state = $results['file_with_data.csv'];\n$isSuccess = !$state-\u003eisError();\n$uploadInfo = $state-\u003eresponseInfo();\n\nprint_r($uploadInfo);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashkarev%2Fclickhouse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbashkarev%2Fclickhouse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashkarev%2Fclickhouse/lists"}