PHPackages                             r4j4h/php-druid-query - 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. [API Development](/categories/api)
4. /
5. r4j4h/php-druid-query

ActiveLibrary[API Development](/categories/api)

r4j4h/php-druid-query
=====================

Experimental PHP wrapper around querying druid

0.2.3(10y ago)1313.5k7[1 PRs](https://github.com/r4j4h/php-druid-query/pulls)1MITPHPPHP &gt;=5.3.0

Since Sep 17Pushed 9y ago3 watchersCompare

[ Source](https://github.com/r4j4h/php-druid-query)[ Packagist](https://packagist.org/packages/r4j4h/php-druid-query)[ RSS](/packages/r4j4h-php-druid-query/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (5)Versions (10)Used By (1)

php-druid-query
===============

[](#php-druid-query)

PHP wrapper around executing HTTP requests to [Druid](http://druid.io). Usually this will be for queries, but can be used for other purposes (such as [ingestion](https://github.com/r4j4h/php-druid-ingest)).

Overview
--------

[](#overview)

The wrapper lives in the namespace `DruidFamiliar`. Druid itself was named in the sprit of the D&amp;D character, and that character could have a familiar - a spiritually linked animal companion. This wrapper in a sense lives as a companion to Druid, and thus the name.

I think the repo name should reflect the namespace for clarity, it currently is `php-druid-query` while the namespace is `DruidFamiliar`. This would be pretty breaking change and will be saved for the future. If you have other suggestions for naming of project or namespaces, feel free to suggest before then.

Changelog
---------

[](#changelog)

0.2.1

- `DruidTime`/`Interval` classes added to make it easier to work with varieties of time inputs to Druid compatible time output.

0.2.0 Major refactoring

- Query and Response Handling separated. All interfaces renamed and redesigned.
    - `IDruidConnection` is now `IDruidQueryExecutor`.
    - `IDruidQuery` is split into `IDruidQueryGenerator` and `IDruidQueryParameters` and `IDruidQueryResponseHandler`.
    - `BaseQuery` is no longer needed, many similar classes were deprecated or removed.
    - `DruidNodeConnection` is now `DruidNodeDruidQueryExecutor`.

0.1.0 Initial release

- Quick sketch for sharing early.

Typical Use
-----------

[](#typical-use)

In general, this wrapper's purpose is to streamline the execution of queries by encapsulating the cruft from the `HTTP` nature of Druid and the analytical grammar in query configuration.

1. Instantiate a connection, configured to hit a Druid endpoint.
2. Instantiate a query generator object for the desired query.
3. Instantiate a query parameters object, configured with desired query parameters.
4. Instantiate a result handler to format the results (otherwise use `DoNothingResponseHandler`)
5. Combine the connection, query, parameters, and response handler to execute it, getting the result from the result handler.

Interface wise, this looks like:

1. Instantiate a `IDruidQueryExecutor`, configured to hit a Druid endpoint.
2. Instantiate a `IDruidQueryGenerator`.
3. Instantiate a `IDruidQueryParameters`, configured with parameters.
4. Instantiate a `IDruidQueryResponseHandler`.
5. Run the `IDruidQueryExecutor`'s `executeQuery` function with the `IDruidQueryGenerator`, `IDruidQueryParameters`, and the `IDruidQueryResponseHandler`, getting the result from the `IDruidQueryResponseHandler`.

Implementation wise, this can look like:

1. Instantiate a `DruidNodeDruidQueryExecutor`, configured to hit a Druid endpoint.
2. Instantiate a `SegmentMetadataDruidQuery`.
3. Instantiate a `SegmentMetadataDruidQueryParameters`, configured with parameters.
4. Instantiate a `SegmentMetadataResponseHandler`.
5. Run the `DruidNodeDruidQueryExecutor`'s `executeQuery` function with the classes spawned in the previous steps, getting the result from `SegmentMetadataResponseHandler`.

How to Install
--------------

[](#how-to-install)

Right now, there is no tagged version. To be ready for it when it comes, branch-aliases are in place.

- Stable branch: `~1.0@dev`
- Cutting edge: `~1.1@dev`

To install, it is suggested to use [Composer](http://getcomposer.org). If you have it installed, then the following instructions in a composer.json should be all you need to get started:

```
{
    "require": {
        "r4j4h/php-druid-query": "~1.0@dev"
    }
}
```

Once that is in, `composer install` and `composer update` should work.

Once those are run, require Composer's autoloader and you are off to the races, or tree circles as it were (bad Druid reference):

1. `require 'vendor/autoload.php';`
2. `$yay = new \DruidFamiliar\Query\TimeBoundaryDruidQuery('my-cool-data-source');`
3. Refer to the [Typical Use](#typical-use) section above.

How to Test
-----------

[](#how-to-test)

Once `composer install` has finished, from the root directory in a command terminal run:

`vendor/bin/phing`

or

`vendor/bin/phpunit tests`

Generate Documentation
----------------------

[](#generate-documentation)

From the root directory, in a command terminal run: `php vendor/bin/phing docs`.

Examples
--------

[](#examples)

Examples are located in the [\\examples](examples) folder.

They share connection information from `_examples-config.php`. Change that match your Druid instance's connection info.

Right now most are designed to run via the CLI, but will work in a browser if a web server running php serves them.

The HTML outputting ones should print the query results to HTML:

[![Example HTML TimeBoundary Output](docs/html-timeboundary-output.png)](docs/html-timeboundary-output.png)

How it Works &amp; How to Extend
--------------------------------

[](#how-it-works--how-to-extend)

Please refer to this diagram for an overview of how this works underneath the hood.

[![Sequence Diagram](docs/sequence-diagram.png)](docs/sequence-diagram.png)

(From this [Dynamic LucidChart Source URL](https://www.lucidchart.com/publicSegments/view/542c92a6-f14c-4520-b004-04920a00caaf/image.png))

In general, to add support for a new query all you need to do is create a new class wherever you want that implements `IDruidQuery`.

By wherever you want, that could be in a fork of this repo, or outside of this repo using this repo's interfaces. That is up to you. :)

References
----------

[](#references)

- [Druid](http://druid.io)
- [Composer](http://getcomposer.org)
- [Guzzle](http://guzzle.readthedocs.org)

Appendix A. Composer.json example that does not rely on Packagist.org:
----------------------------------------------------------------------

[](#appendix-a-composerjson-example-that-does-not-rely-on-packagistorg)

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:r4j4h/php-druid-query"
        }
    ],
    "require": {
        "r4j4h/php-druid-query": "~1.0@dev"
    }
}
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.6% 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 ~85 days

Recently: every ~125 days

Total

7

Last Release

3793d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/84c480751333fa4e6bb8de34b6254ed66d421c576bc3f5b50795df692917b31a?d=identicon)[r4j4h](/maintainers/r4j4h)

---

Top Contributors

[![r4j4h](https://avatars.githubusercontent.com/u/703007?v=4)](https://github.com/r4j4h "r4j4h (123 commits)")[![epeimbert-tiempodev](https://avatars.githubusercontent.com/u/6250174?v=4)](https://github.com/epeimbert-tiempodev "epeimbert-tiempodev (14 commits)")[![tadeo-3pillar](https://avatars.githubusercontent.com/u/6199831?v=4)](https://github.com/tadeo-3pillar "tadeo-3pillar (9 commits)")[![brianwebpt](https://avatars.githubusercontent.com/u/2730228?v=4)](https://github.com/brianwebpt "brianwebpt (3 commits)")

---

Tags

querydruidqueryingparameterized query

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/r4j4h-php-druid-query/health.svg)

```
[![Health](https://phpackages.com/badges/r4j4h-php-druid-query/health.svg)](https://phpackages.com/packages/r4j4h-php-druid-query)
```

###  Alternatives

[gmostafa/php-graphql-client

GraphQL client and query builder.

3218.2M29](/packages/gmostafa-php-graphql-client)[planetteamspeak/ts3-php-framework

Modern use-at-will framework that provides individual components to manage TeamSpeak 3 Server instances

21690.9k5](/packages/planetteamspeak-ts3-php-framework)[gmostafa/php-graphql-oqm

GraphQL Object-to-Query Mapper (QOM) which generates objects from API schema

44937.4k2](/packages/gmostafa-php-graphql-oqm)[getkirby/kql

Kirby Query Language

15027.0k](/packages/getkirby-kql)[joskolenberg/laravel-jory

Create a flexible API for your Laravel application using json based queries.

4514.2k](/packages/joskolenberg-laravel-jory)[coincheck/coincheck

Bindings of coincheck API

202.2k](/packages/coincheck-coincheck)

PHPackages © 2026

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