2017 © Pedro Peláez
 

library cube-php

A PHP client for Cube

image

showclix/cube-php

A PHP client for Cube

  • Tuesday, April 8, 2014
  • by nategood
  • Repository
  • 31 Watchers
  • 8 Stars
  • 4,626 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Cube Client for PHP

Cube Client that supports communicating with a Cube collector and evaluator., (*1)

Usage

// Create a Client pointed at a local collector and evaluator
$client = \Cube\Client::createHttpClient(array(
    'collector' => array(
        'host' => 'localhost',
        'port' => 1080,
    ),
    'evaluator' => array(
        'host' => 'localhost',
        'port' => 1081,
    ),
    'secure' => true,
));

$res = $client->metricGet(array(
    'expression' => 'sum(cube_request)',
    'step' => \Cube\Client::INT_ONE_MINUTE,
    'limit' => 100,
));

echo "There were {$res[0]['value']} hits during {$res[0]['time']}";

Install

Via composer, (*2)

composer.phar install showclix/cube-php

API

\Cube\Client

[static] createHttpClient(array $conf)

param array $conf, (*3)

Configuration array. For example:, (*4)

array(
    'collector' => array(
        'host' => 'localhost',
        'port' => 1080,
    ),
    'evaluator' => array(
        'host' => 'localhost',
        'port' => 1081,
    ),
    'secure' => true,
)

return \Cube\Client, (*5)

eventPut(array $event)

param array $event, (*6)

The event to push to cube. Requires type, time and data options., (*7)

array(
    'type' => 'example',
    'time' => time(),
    'data' => array(
        'key' => 'value',
    ),
)

returns array response from Cube, (*8)

eventGet(array $query)

param array $query, (*9)

returns array, (*10)

EXAMPLE, (*11)

$query = array(
    'expression' => 'request.eq(path, "search")',   // cube expression
    'limit' => 10,                                  // limit (optional)
);
$client->metricGet($query);

metricGet(array $query)

param array $query Metric query to send to cube evaluator, (*12)

returns array, (*13)

EXAMPLE, (*14)

$query = array(
    'expression' => 'sum(type_name)',   // cube expression
    'start' => strtotime('-1 day'),     // start time (optional)
    'stop' => time(),                   // end time (optional)
    'limit' => 10,                      // limit (optional)
    'step' => Client::INT_ONE_MINUTE,   // time grouping interval
);
$res = $client->metricGet($query);
echo "There were {$res[0]['value']} during {$res[0]['time']}";

typesGet()

returns array of all types currently in cube, (*15)

Todo

  • Implement \Cube\Connection\WebSocketConnection
  • Implement \Cube\Connection\UdpConnection
  • Add Travis CI Integaration complete with hooks to setup and install Cube/Mongo

The Versions

08/04 2014

dev-master

9999999-dev http://github.com/ShowClix/cube-php

A PHP client for Cube

  Sources   Download

MIT

The Requires

 

analytics cube

08/04 2014

0.1.1

0.1.1.0 http://github.com/ShowClix/cube-php

A PHP client for Cube

  Sources   Download

MIT

The Requires

 

analytics cube

11/09 2013

0.1.0

0.1.0.0 http://github.com/ShowClix/cube-php

A PHP client for Cube

  Sources   Download

MIT

The Requires

 

analytics cube

28/02 2013

0.0.1

0.0.1.0 http://github.com/ShowClix/cube-php

A PHP client for Cube

  Sources   Download

MIT

The Requires

 

analytics cube