PHP code example of hgg / metrics

1. Go to this page and download the library: Download hgg/metrics 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/ */

    

hgg / metrics example snippets



$metrics = new Metrics(true);
$metrics->myCounter = 0;

while (1) {
    // Do some work
    ++$metrics->myCounter;
}

print_r($metrics->toArray());


$metrics = new Metrics(true);
$metrics->initMembers(array('counter1', 'counter2', 'counter3'), 0);


$arrayResult = $metrics->toArray();


$json = $metrics->toJson();
json
{
  "counter1": 23,
  "counter2": 569,
  "counter3": 0,
  "elapsed-time": "00:00:24"
}