1. Go to this page and download the library: Download edisonlabs/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/ */
edisonlabs / metrics example snippets
// src/EdisonLabs/Metric/NumberOfPhpFiles.php
namespace EdisonLabs\Metric;
use EdisonLabs\Metrics\Metric\AbstractMetricBase;
class NumberOfPhpFiles extends AbstractMetricBase
{
public function getName()
{
return 'Number of PHP files';
}
public function getDescription()
{
return 'The total number of PHP files';
}
public function getMetric()
{
// Put the logic to calculate the total of PHP files here.
// ..
// Random example.
return rand(10, 50);
}
}
// collector.php
use EdisonLabs\Metrics\Collector;
$date = strtotime('now');
$config = array();
$collector = new Collector($date, $config);
$metrics = $collector->getMetrics();
// src/EdisonLabs/Metric/Datastore/SqLite.php
namespace EdisonLabs\Metric\Datastore;
use EdisonLabs\Metrics\Metric\Datastore\AbstractMetricDatastore;
class SqLite extends AbstractMetricDatastore
{
public function getName()
{
return 'SQLite';
}
public function getDescription()
{
return 'Stores metrics to SQLite';
}
public function save()
{
$metrics = $this->getMetrics();
// Put your logic to store the metrics to SQLite here.
return true;
}
}
// datastore.php
use EdisonLabs\Metrics\Collector;
use EdisonLabs\Metrics\DatastoreHandler;
$date = strtotime('now');
$config = array();
$collector = new Collector($date, $config);
$metrics = $collector->getMetrics();
$datastoreHandler = new DatastoreHandler($date, $config);
$datastore = $datastoreHandler->getDatastoreByName('SQLite');
$datastore->setMetrics($metrics);
$datastore->save();
composer dump-autoload
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.