PHPackages                             monitaroo/monitaroo-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. monitaroo/monitaroo-php

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

monitaroo/monitaroo-php
=======================

Official Monitaroo SDK for PHP - Logs, Metrics &amp; Monitoring

v2.0.2(1w ago)036—0%1MITPHPPHP ^8.0

Since Mar 12Pushed 1w agoCompare

[ Source](https://github.com/Monitaroo/monitaroo-php)[ Packagist](https://packagist.org/packages/monitaroo/monitaroo-php)[ Docs](https://github.com/Monitaroo/monitaroo-php)[ RSS](/packages/monitaroo-monitaroo-php/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (8)Used By (1)

Monitaroo PHP SDK
=================

[](#monitaroo-php-sdk)

Official PHP SDK for [Monitaroo](https://monitaroo.com) - Logs, Metrics &amp; Monitoring.

[![Latest Version](https://camo.githubusercontent.com/698d89c7f672ef331734c2da1442e53f157cb9f1183aa82f2c1f22cbdca2f1d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f6e697461726f6f2f6d6f6e697461726f6f2e737667)](https://packagist.org/packages/monitaroo/monitaroo)[![PHP Version](https://camo.githubusercontent.com/3da04f603a5163e13291fc3b09f0e80ae65870e8e8471d3eba0dd392232221dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6f6e697461726f6f2f6d6f6e697461726f6f2e737667)](https://packagist.org/packages/monitaroo/monitaroo)[![License](https://camo.githubusercontent.com/886bbc1c773ac2d13631fed5ba3fd88b7a45b44a1d6a24317600f53aeca3ea7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6f6e697461726f6f2f6d6f6e697461726f6f2e737667)](https://packagist.org/packages/monitaroo/monitaroo)

Installation
------------

[](#installation)

```
composer require monitaroo/monitaroo
```

**Requirements:** PHP 8.0+

Quick Start
-----------

[](#quick-start)

```
use Monitaroo\Monitaroo;

// Initialize once (e.g., in bootstrap)
Monitaroo::init([
    'apiKey' => 'mk_your_api_key',
    'service' => 'my-app',
    'environment' => 'production',
]);

// Log messages (buffered, auto-flushed at end of request)
Monitaroo::info('User logged in', ['user_id' => 123]);
Monitaroo::error('Payment failed', ['order_id' => 456, 'tags' => ['type' => 'payment']]);

// Record metrics
Monitaroo::increment('orders.completed');
Monitaroo::gauge('queue.size', 42);
Monitaroo::timing('api.response_time', 145.5);

// Timer helper
$stop = Monitaroo::startTimer('db.query');
$result = $db->query('SELECT ...');
$elapsed = $stop(); // Automatically records the metric
```

Configuration
-------------

[](#configuration)

```
Monitaroo::init([
    // Required
    'apiKey' => 'mk_xxx',           // Your API key from Monitaroo dashboard

    // Optional - Default context for all logs
    'service' => 'my-app',          // Service name
    'environment' => 'production',  // Environment (production, staging, dev)
    'host' => 'server-01',          // Host name (auto-detected if not set)

    // Optional - Performance tuning
    'endpoint' => 'https://api.monitaroo.com',  // API endpoint
    'batchSize' => 100,             // Flush after N items (default: 100)
    'autoFlush' => true,            // Auto-flush on shutdown (default: true)
]);
```

Logging
-------

[](#logging)

### Log Levels

[](#log-levels)

```
Monitaroo::trace('Detailed trace info');
Monitaroo::debug('Debug information');
Monitaroo::info('General information');
Monitaroo::warn('Warning message');
Monitaroo::error('Error occurred');
Monitaroo::fatal('Fatal error');
```

### Context &amp; Tags

[](#context--tags)

```
// Context becomes attributes (searchable metadata)
Monitaroo::info('Order placed', [
    'order_id' => 123,
    'amount' => 99.99,
    'customer' => 'john@example.com',
]);

// Tags are indexed for fast filtering
Monitaroo::info('Order placed', [
    'order_id' => 123,
    'tags' => [
        'type' => 'order',
        'country' => 'FR',
    ],
]);
```

### Exception Logging

[](#exception-logging)

```
try {
    // ...
} catch (\Exception $e) {
    Monitaroo::error('Operation failed', [
        'exception' => $e,  // Automatically extracts class, message, trace
    ]);
}
```

### PSR-3 Logger

[](#psr-3-logger)

```
use Monitaroo\Monitaroo;

// Get PSR-3 compatible logger
$logger = Monitaroo::logger();

// Use with any PSR-3 compatible library
$logger->info('Hello {name}', ['name' => 'World']);
```

Metrics
-------

[](#metrics)

### Counter (increments)

[](#counter-increments)

```
// Simple increment
Monitaroo::increment('api.requests');

// Increment by value
Monitaroo::increment('items.sold', 5);

// With tags
Monitaroo::increment('api.requests', 1, [
    'endpoint' => '/users',
    'method' => 'GET',
]);
```

### Gauge (current value)

[](#gauge-current-value)

```
Monitaroo::gauge('queue.size', 142);
Monitaroo::gauge('memory.used_mb', memory_get_usage(true) / 1024 / 1024);
Monitaroo::gauge('connections.active', $pool->getActiveCount(), [
    'pool' => 'database',
]);
```

### Timer (durations)

[](#timer-durations)

```
// Manual timing (milliseconds)
$start = microtime(true);
$result = doSomething();
$elapsed = (microtime(true) - $start) * 1000;
Monitaroo::timing('operation.duration', $elapsed);

// Using helper
$stop = Monitaroo::startTimer('db.query', ['table' => 'users']);
$users = $db->query('SELECT * FROM users');
$stop(); // Records metric automatically
```

### Histogram (distributions)

[](#histogram-distributions)

```
Monitaroo::histogram('order.amount', $order->total);
Monitaroo::histogram('file.size_kb', filesize($path) / 1024);
```

Flushing
--------

[](#flushing)

By default, logs and metrics are buffered and automatically flushed:

- When batch size is reached (default: 100)
- At the end of the request (`register_shutdown_function`)
- Using `fastcgi_finish_request()` if available (response sent first)

### Manual Flush

[](#manual-flush)

```
// Force immediate flush
Monitaroo::flush();
```

### Disable Auto-Flush

[](#disable-auto-flush)

```
Monitaroo::init([
    'apiKey' => 'mk_xxx',
    'autoFlush' => false,  // Manual flush only
]);

// Must call flush manually
Monitaroo::flush();
```

Framework Integration
---------------------

[](#framework-integration)

### Laravel

[](#laravel)

Use the dedicated Laravel package for seamless integration:

```
composer require monitaroo/monitaroo-laravel
```

See [monitaroo/monitaroo-laravel](https://github.com/Monitaroo/monitaroo-laravel) for details.

### Symfony

[](#symfony)

Use the dedicated Symfony bundle:

```
composer require monitaroo/monitaroo-symfony
```

See [monitaroo/monitaroo-symfony](https://github.com/Monitaroo/monitaroo-symfony) for details.

Advanced Usage
--------------

[](#advanced-usage)

### Custom Transport

[](#custom-transport)

```
use Monitaroo\Client;
use Monitaroo\Transport\TransportInterface;

class MyTransport implements TransportInterface
{
    public function sendLogs(array $logs): void
    {
        // Custom implementation
    }

    public function sendMetrics(array $metrics): void
    {
        // Custom implementation
    }
}

$client = new Client([
    'apiKey' => 'mk_xxx',
    'transport' => new MyTransport(),
]);
```

### Multiple Clients

[](#multiple-clients)

```
use Monitaroo\Client;

$clientA = new Client(['apiKey' => 'mk_app_a', 'service' => 'app-a']);
$clientB = new Client(['apiKey' => 'mk_app_b', 'service' => 'app-b']);

$clientA->info('From app A');
$clientB->info('From app B');
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance98

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

7

Last Release

9d ago

Major Versions

v1.0.1 → v2.0.12026-03-12

PHP version history (2 changes)v2.0.0PHP ^8.0

v1.0.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/00d4e26523d2e5c8cc70b00b5dbfbe0dd4c51b9881d9bcd6d230856c26873549?d=identicon)[anivon](/maintainers/anivon)

---

Top Contributors

[![anivon](https://avatars.githubusercontent.com/u/4992953?v=4)](https://github.com/anivon "anivon (1 commits)")

---

Tags

loggingmonitoringMetricsapmobservabilitymonitaroo

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/monitaroo-monitaroo-php/health.svg)

```
[![Health](https://phpackages.com/badges/monitaroo-monitaroo-php/health.svg)](https://phpackages.com/packages/monitaroo-monitaroo-php)
```

###  Alternatives

[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2121.3M165](/packages/open-telemetry-sdk)[open-telemetry/api

API for OpenTelemetry PHP.

1730.6M139](/packages/open-telemetry-api)[friendsofopentelemetry/opentelemetry-bundle

Traces, metrics, and logs instrumentation within your Symfony application

568.0k](/packages/friendsofopentelemetry-opentelemetry-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
