Download the PHP package bavix/clickhouse-php-client without Composer

On this page you can find all versions of the php package bavix/clickhouse-php-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-php-client

Clickhouse Client

Build Status Coverage Status

Package was written as client for Clickhouse.

Client uses Guzzle for sending Http requests to Clickhouse servers.

Requirements

php7.1

Install

Composer

Usage

Client works with alone server and cluster. Also, client can make async select and insert (from local files) queries.

Alone server

Cluster

Before execute any query on cluster, you should provide cluster name and client will run all queries on specified cluster.

By default client will use random server in given list of servers or in specified cluster. If you want to perform request on specified server you should use using($hostname) method on client and then run query. Client will remember hostname for next queries:

Server tags

To use server with tag, you should call function before execute any query.

Select queries

Any SELECT query will return instance of Result. This class implements interfaces \ArrayAccess, \Countable и \Iterator, which means that it can be used as an array.

Array with result rows can be obtained via rows property

Also you can get some statistic of your query execution:

  1. Number of read rows
  2. Number of read bytes
  3. Time of query execution
  4. Rows before limit at least

Statistic can be obtained via statistic property

Sync

Using local files

You can use local files as temporary tables in Clickhouse. You should pass as third argument array of TempTable instances. instance.

In this case will be sent one file to the server from which Clickhouse will extract data to temporary table. Structure of table will be:

If you pass such an array as a structure:

Then each column from file wil be named as _1, _2, _3.

You can provide path to file or pass FileInterface instance as second argument.

There is some other types of file streams which could be used to send to server:

Async

Unlike the readOne method, which returnsResult, the read method returns an array ofResult for each executed query.

In read method, you can pass the parameter $concurrency which is responsible for the maximum simultaneous number of requests.

Using local files

As with synchronous select request you can pass files to the server:

With asynchronous requests you can pass multiple files as with synchronous request.

Insert queries

Insert queries always returns true or throws exceptions in case of error.

Data can be written row by row or from local CSV or TSV files.

In case of writeFiles queries executes asynchronously. If you have butch of files and you want to insert them in one insert query, you can use our ccat utility and MergedFiles instance instead of File. You should put list of files to insert into one file:

Building ccat

ccat sources placed into utils/ccat directory. Just run make && make install to build and install library into bin directory of package. There are already compiled binary of ccat in bin directory, but it may not work on some systems.

In writeFiles method, you can pass the parameter $concurrency which is responsible for the maximum simultaneous number of requests.

Other queries

In addition to SELECT and INSERT queries, you can execute other queries :) There is statement method for this purposes.

Testing

Roadmap

Contributing

Please send your own pull-requests and make suggestions on how to improve anything. We will be very grateful.

Thx!


All versions of clickhouse-php-client with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8.0
guzzlehttp/guzzle Version ^6.0|^7.0
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 bavix/clickhouse-php-client contains the following files

Loading the files please wait ....