1. Go to this page and download the library: Download pixelfederation/druid-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pixelfederation / druid-php example snippets
use Druid\Druid;
use Druid\Driver\Guzzle\Driver;
use Druid\Query\AbstractQuery;
use Druid\Query\Component\Granularity\PeriodGranularity;
$druid = new Druid(
new Driver(),
[
'scheme' => 'http',
'host' => 'localhost',
'port' => '9999',
'path' => '/druid/v2',
'proxy' => 'tcp://127.0.0.1:8080', // default null
'timeout' => 3.7, // in seconds - default null
]
);
$queryBuilder = $druid->createQueryBuilder(AbstractQuery::TYPE_GROUP_BY); // or AbstractQuery::TYPE_TIMESERIES
$queryBuilder->setDataSource('kpi_registrations_v1');
$queryBuilder->addInterval(new \DateTime('2000-01-01'), new \DateTime());
$granularity = new PeriodGranularity('P1D', 'UTC');
$queryBuilder->setGranularity($granularity);
$queryBuilder->addAggregator($queryBuilder->aggregator()->count('count_rows'));
$queryBuilder->addAggregator($queryBuilder->aggregator()->doubleSum('sum_rows', 'event_count_metric'));
$queryBuilder->addAggregator($queryBuilder->aggregator()->hyperUnique('registrations', 'registrations'));
// Only
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.