Download the PHP package simpod/clickhouse-client without Composer

On this page you can find all versions of the php package simpod/clickhouse-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package clickhouse-client

PHP ClickHouse Client

Build Status Code Coverage Downloads Infection MSI

Motivation

The library is trying not to hide any ClickHouse HTTP interface specific details. That said everything is as much transparent as possible and so object-oriented API is provided without inventing own abstractions.
Naming used here is the same as in ClickHouse docs.

Contents

Setup

  1. Read about ClickHouse Http Interface. It's short and useful for concept understanding.
  2. Create a new instance of ClickHouse client and pass PSR factories.
    1. Symfony HttpClient is recommended (performance, less bugs, maintenance)
    2. The plot twist is there's no endpoint/credentials etc. config in this library, provide it via client
  3. See tests

Symfony HttpClient Example

Configure HTTP Client

As said in ClickHouse HTTP Interface spec, we use headers to auth and e.g. set default database via query.

PSR Factories who?

The library does not implement it's own HTTP. That has already been done via PSR-7, PSR-17 and PSR-18. This library respects it and allows you to plug your own implementation (eg. HTTPPlug or Guzzle).

Recommended are composer require nyholm/psr7 for PSR-17 and composer require php-http/curl-client for Curl PSR-18 implementation (used in example above).

Sync API

Select

ClickHouseClient::select()

Intended for SELECT and SHOW queries. Appends FORMAT to the query and returns response in selected output format:

Select With Params

ClickHouseClient::selectWithParams()

Same as ClickHouseClient::select() except it also allows parameter binding.

Insert

ClickHouseClient::insert()

If $columnNames is provided and is key->value array column names are generated based on it and values are passed as parameters:

$client->insert( 'table', [[1,2]], ['a' => 'Int8, 'b' => 'String'] ); generates INSERT INTO table (a,b) VALUES ({p1:Int8},{p2:String}) and values are passed along the query.

If $columnNames is provided column names are generated based on it:

$client->insert( 'table', [[1,2]], ['a', 'b'] ); generates INSERT INTO table (a,b) VALUES (1,2).

If $columnNames is omitted column names are read from $data:

$client->insert( 'table', [['a' => 1,'b' => 2]]); generates INSERT INTO table (a,b) VALUES (1,2).

Column names are read only from the first item:

$client->insert( 'table', [['a' => 1,'b' => 2], ['c' => 3,'d' => 4]]); generates INSERT INTO table (a,b) VALUES (1,2),(3,4).

If not provided they're not passed either:

$client->insert( 'table', [[1,2]]); generates INSERT INTO table VALUES (1,2).

Async API

Select

Parameters "binding"

This produces SELECT 'value' and it can be passed to ClickHouseClient::select().

Supported types are:

Native Query Parameters

[!TIP] Official docs

All types are supported (except AggregateFunction, SimpleAggregateFunction and Nothing by design). You can also pass DateTimeInterface into Date* types or native array into Array, Tuple, Native and Geo types

Custom Query Parameter Value Conversion

Query parameters passed to selectWithParams() are converted into an HTTP-API-compatible format. To overwrite an existing value converter or provide a converter for a type that the library does not (yet) support, pass these to the SimPod\ClickHouseClient\Param\ParamValueConverterRegistry constructor:

Be aware that the library can not ensure that passed values have a certain type. They are passed as-is and closures must accept mixed values.

Throw an exception of type UnsupportedParamValue if your converter does not support the passed value type.

Expression

To represent complex expressions there's SimPod\ClickHouseClient\Sql\Expression class. When passed to SqlFactory its value gets evaluated.

To pass eg. UUIDStringToNum('6d38d288-5b13-4714-b6e4-faa59ffd49d8') to SQL:

Snippets

There are handy queries like getting database size, table list, current database etc.

To prevent Client API pollution, those are extracted into Snippets.

Example to obtain current database name:

List


All versions of clickhouse-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/promises Version ^2.0
guzzlehttp/psr7 Version ^2.6
php-http/client-common Version ^2.0
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/log Version ^3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package simpod/clickhouse-client contains the following files

Loading the files please wait ....