{"id":13795574,"url":"https://github.com/pixelfederation/druid-php","last_synced_at":"2025-06-30T05:04:37.354Z","repository":{"id":57042093,"uuid":"63238232","full_name":"pixelfederation/druid-php","owner":"pixelfederation","description":"Druid driver for PHP","archived":false,"fork":false,"pushed_at":"2017-06-16T13:19:41.000Z","size":228,"stargazers_count":34,"open_issues_count":2,"forks_count":14,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-11T14:13:28.219Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pixelfederation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-13T10:46:46.000Z","updated_at":"2022-10-14T00:14:14.000Z","dependencies_parsed_at":"2022-08-24T00:51:19.670Z","dependency_job_id":null,"html_url":"https://github.com/pixelfederation/druid-php","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/pixelfederation/druid-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelfederation%2Fdruid-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelfederation%2Fdruid-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelfederation%2Fdruid-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelfederation%2Fdruid-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixelfederation","download_url":"https://codeload.github.com/pixelfederation/druid-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelfederation%2Fdruid-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262714507,"owners_count":23352463,"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":[],"created_at":"2024-08-03T23:00:58.896Z","updated_at":"2025-06-30T05:04:37.323Z","avatar_url":"https://github.com/pixelfederation.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Druid PHP driver\n\nThis library provider a [Druid](http://druid.io/) PHP Driver.\n\n## [License](LICENSE)\n\n## Instalation\n\nInstallation of this library uses composer. For composer documentation, please refer to\n[getcomposer.org](http://getcomposer.org/).\n\nPut the following into your composer.json\n\n    {\n        \"require\": {\n            \"pixelfederation/druid-php\": \"dev-master\"\n        }\n    }\n\n## Current State\n\nCurrently this driver supports **GroupBy, TopN** and **Timeseries** aggregation types, and **Search** query type.\nEverybody is welcome to create pull requests to implement some of the missing things.\n\nAlso, some unit tests are bound to running on our internal Druid instance, there is plan to change it to docker container\nwith some testing data.\n\n## Usage\n\n### Average aggregation\n\n```php\n\u003c?php\n\nuse Druid\\Druid;\nuse Druid\\Driver\\Guzzle\\Driver;\nuse Druid\\Query\\AbstractQuery;\nuse Druid\\Query\\Component\\Granularity\\PeriodGranularity;\n\n$druid = new Druid(\n    new Driver(),\n    [\n        'scheme' =\u003e 'http',\n        'host' =\u003e 'localhost',\n        'port' =\u003e '9999',\n        'path' =\u003e '/druid/v2',\n        'proxy' =\u003e 'tcp://127.0.0.1:8080', // default null\n        'timeout' =\u003e 3.7, // in seconds - default null\n    ]\n);\n\n$queryBuilder = $druid-\u003ecreateQueryBuilder(AbstractQuery::TYPE_GROUP_BY); // or AbstractQuery::TYPE_TIMESERIES\n\n$queryBuilder-\u003esetDataSource('kpi_registrations_v1');\n$queryBuilder-\u003eaddInterval(new \\DateTime('2000-01-01'), new \\DateTime());\n\n$granularity = new PeriodGranularity('P1D', 'UTC');\n$queryBuilder-\u003esetGranularity($granularity);\n\n$queryBuilder-\u003eaddAggregator($queryBuilder-\u003eaggregator()-\u003ecount('count_rows'));\n$queryBuilder-\u003eaddAggregator($queryBuilder-\u003eaggregator()-\u003edoubleSum('sum_rows', 'event_count_metric'));\n$queryBuilder-\u003eaddAggregator($queryBuilder-\u003eaggregator()-\u003ehyperUnique('registrations', 'registrations'));\n\n// Only include for GroupBy queries\n$queryBuilder-\u003eaddDimension('project', 'project');\n\n$queryBuilder-\u003eaddPostAggregator(\n    $queryBuilder-\u003epostAggregator()-\u003earithmeticPostAggregator(\n        'average',\n        '/',\n        [\n            $queryBuilder-\u003epostAggregator()-\u003efieldAccessPostAggregator('sum_rows', 'sum_rows'),\n            $queryBuilder-\u003epostAggregator()-\u003efieldAccessPostAggregator('count_rows', 'count_rows')\n        ]\n    )\n);\n\n$response = $druid-\u003esend($queryBuilder-\u003egetQuery());\n```\n\n## Contribution\n\nIf you'd like to contribtue, we strongly recommend to run\n\n```bash\n./bin/setup-dev\n```\n\nfrom the project directory. This script will set up a commit hook, which checks the PSR/2 coding standards\nusing [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) and also runs PHP linter and\nPHP Mess Detector [PHPMD](http://phpmd.org/)\n\n## TODO\n\n1. **Query types**\n    * Metadata Queries\n        * Time Boundary\n        * Segment Metadata\n        * Datasource Metadata\n2. **Components**\n    * Data source\n        * query\n    * Aggregations\n        * Cardinality aggregator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelfederation%2Fdruid-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixelfederation%2Fdruid-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelfederation%2Fdruid-php/lists"}