1. Go to this page and download the library: Download runomine/runomine-php 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/ */
runomine / runomine-php example snippets
use Rom; // or Runomine\Laravel\Facades\Rom
Rom::track('signup');
Rom::track('purchase', ['plan' => 'rent', 'film' => 'the-third-man'], ['amount' => 4.99, 'currency' => 'EUR']);
// Your own payment webhook, for payments no connected provider sees (see "Revenue from your payment provider"):
// no browser behind it, but you know who paid.
Rom::track('purchase', ['plan' => 'yearly'], ['amount' => 49, 'currency' => 'EUR'], user: $order->user_id);
// Hand the visitor to a queued job when it should count as the same visit.
ProcessCheckout::dispatch($order, Rom::visitor());
// ...and in the job:
Rom::track('checkout_completed', context: ['visitor' => $this->visitor]);
$request->attributes->set('runomine.props', ['section' => 'news']); // the middleware sends them
Rom::pageview($request, ['props' => ['section' => 'news', 'area' => 'public']]); // or by hand
$rom = new Runomine\Client(); // reads RUNOMINE_TOKEN, RUNOMINE_URL, RUNOMINE_ENABLED
// or: new Runomine\Client(token: 'rm_live_...');
// In your front controller, for HTML pages:
$rom->pageview([
'url' => (($_SERVER['HTTPS'] ?? '') === 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],
'referrer' => $_SERVER['HTTP_REFERER'] ?? null,
'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? null,
'ip' => $_SERVER['REMOTE_ADDR'], // hashed here, never sent
'country' => $_SERVER['HTTP_CF_IPCOUNTRY'] ?? null,
'user' => $_SESSION['user_id'] ?? null,
'props' => ['section' => 'news'], // optional, stored as the page view's dims
]);
// Anywhere:
$rom->track('purchase', ['plan' => 'rent'], ['amount' => 4.99, 'currency' => 'EUR'], user: '42', context: [
'url' => 'https://example.com/checkout/success',
'ip' => $_SERVER['REMOTE_ADDR'],
'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
]);
// Optional: send now. Otherwise it flushes at 500 events, after 5 seconds, on destruct and at shutdown.
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request(); // let the visitor go first
}
$rom->flush();
$ok = Rom::sample(['queue' => ['pending' => 3, 'failed' => 0], 'healthy' => true]); // or $client->sample(...)
$ok = Rom::sample(['cpu' => 0.12], new DateTimeImmutable('2026-10-14 10:00:00Z')); // measured earlier
// A catch-up, in calls of at most 500:
$ok = $client->samples([['ts' => '2026-10-14T10:00:00Z', 'data' => ['cpu' => 0.1]], ['ts' => '2026-10-14T10:01:00Z', 'data' => ['cpu' => 0.2]]]);
Rom::checkoutMetadata(); // ['runomine_visitor' => '5f9e1bebe31e8bf5', 'runomine_user' => '42']
Rom::checkoutMetadata($team->id); // your own id instead of the logged-in user's
// Plain PHP: ip, user agent, host and user
$rom->checkoutMetadata($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'] ?? '', $_SERVER['HTTP_HOST'], $userId);
$sender = new Runomine\Testing\FakeSender(); // or new FakeSender([503, 202]) to script answers
$client = new Runomine\Client(token: 'rm_live_test', sender: $sender);
$client->track('signup');
$client->flush();
$sender->events(); // the events, as sent
$sender->samples(); // the samples, as sent
$sender->requests(); // url, headers, body of every call
sh
php artisan vendor:publish --tag=runomine-config
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.