1. Go to this page and download the library: Download jarir-ahmed/server-stats 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/ */
jarir-ahmed / server-stats example snippets
use JarirAhmed\ServerStats\{Storage, Metrics, MetricCollector};
$storage = new Storage(); // MySQL if reachable, else SQLite in the system temp dir
Metrics::init($storage);
// Counter — atomic, durable across requests/processes
Metrics::counter('page_views.home')->increment();
// Gauge — point-in-time value (latest wins)
Metrics::gauge('queue.depth')->set(42);
// Timer — measure a block; stops even if the callback throws
$result = Metrics::measure('request.processing', function () {
return doWork();
});
// System metrics (CPU load, memory, disk)
(new MetricCollector($storage))->recordSystemMetrics();
use JarirAhmed\ServerStats\{Registry, InMemoryStorage};
$registry = new Registry(new InMemoryStorage());
$registry->counter('hits')->increment();
$registry->gauge('temp')->set(21.5);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.