PHP code example of openclerk / metrics

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

    

openclerk / metrics example snippets


$migrations = new AllMigrations(db());
if ($migrations->hasPending(db())) {
  $migrations->install(db(), $logger);
}

Openclerk\Config::merge(array(
  // these are default values
  "metrics_enabled" => true,
  "metrics_db_enabled" => true,
  "metrics_page_enabled" => true,
  "metrics_templates_enabled" => true,

  // store reports into the database
  "metrics_store" => false,
));

// set up metrics
Openclerk\MetricsHandler::init(db());

// trigger page load metrics
Openclerk\Events::trigger('page_init', null);

// when rendering a page...
Openclerk\Events::trigger('page_start', null);
// do things
Openclerk\Events::trigger('page_end', null);

// print out metrics stats
print_r(Openclerk\MetricsHandler::getInstance()->printResults());