PHPackages                             mindtwo/base-monitoring - 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. mindtwo/base-monitoring

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

mindtwo/base-monitoring
=======================

Framework-agnostic core of the mindtwo monitoring suite. Safely collects infrastructure, package and security-audit data and ships it as a signed snapshot.

v1.0.0(1mo ago)0196↓45.5%1MITPHPPHP ^8.0CI passing

Since Jun 19Pushed 1mo agoCompare

[ Source](https://github.com/mindtwo/base-monitoring)[ Packagist](https://packagist.org/packages/mindtwo/base-monitoring)[ Docs](https://github.com/mindtwo/base-monitoring)[ RSS](/packages/mindtwo-base-monitoring/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (6)Versions (2)Used By (1)

mindtwo/base-monitoring
=======================

[](#mindtwobase-monitoring)

[![Tests](https://github.com/mindtwo/base-monitoring/actions/workflows/tests.yml/badge.svg)](https://github.com/mindtwo/base-monitoring/actions/workflows/tests.yml)[![PHPStan Level 8](https://camo.githubusercontent.com/ff3c7f8c8667ce643f47e74532748f673482a5f95d7d4269f925f2eebbe5117e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e)](phpstan.neon.dist)[![PHP 8.0+](https://camo.githubusercontent.com/911a83e2aa6fe73660ab613629a95c76622bf03049a7344e80c5ea72d4ef9c7d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d626c7565)](composer.json)[![License: MIT](https://camo.githubusercontent.com/be07a68b57a673af622198c336264f89d82bf4cd5d87bc0cb3f7b6ae47cc43ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d6c6967687467726579)](LICENSE.md)

The framework-agnostic **collecting core** of the mindtwo monitoring suite. It safely gathers infrastructure, package and security-audit data from any PHP environment and ships it as a signed, versioned JSON snapshot — either pushed to the central monitoring endpoint or served through a plugin's pull endpoint.

Framework plugins build on this core:

PackageAdds[`mindtwo/laravel-monitoring`](https://github.com/mindtwo/laravel-monitoring)Laravel collectors, scheduler push, signed pull endpoint[`mindtwo/wordpress-monitoring`](https://github.com/mindtwo/wordpress-monitoring)WordPress core/plugin/theme collectors, WP-Cron push[`mindtwo/craftcms-monitoring`](https://github.com/mindtwo/craftcms-monitoring)Craft CMS collectors, console/queue push[`mindtwo/server-monitoring`](https://github.com/mindtwo/server-monitoring)Standalone server-level monitoring (Docker, load)What it collects
----------------

[](#what-it-collects)

Metric keySource`os``/etc/os-release` (Linux), `sw_vers` (macOS), `php_uname()` fallback`php``PHP_VERSION`, SAPI, memory limit — always available`database`best-effort CLI client detection (`mysql`/`mariadb`/`psql`/`sqlite3`) — plugins override with the live connection`nginx`, `apache`, `caddy`, `redis`version output of the respective binary, when installed`node``node --version` plus the npm version`system`CPU count, total/available memory, total/free disk`composer_packages`parsed offline from `composer.lock`, with dev/direct flags`npm_packages`parsed offline from `package-lock.json` (v1–v3), `npm-shrinkwrap.json`, `yarn.lock` (classic &amp; berry) or `pnpm-lock.yaml` (v6 &amp; v9)`composer_audit``composer audit --format=json` — advisories and abandoned packages`composer_licenses``composer licenses --format=json` — license summary and per-package list`npm_audit``npm audit --json` — severity counts plus per-advisory detail`git`branch, commit, dirty state, changed files (capped)Detected software is normalized to a **technology slug** pinned from [endoflife.date](https://endoflife.date), so the central dashboard can match versions against end-of-life data. Unknown software degrades to a slug derived from the package or `org/repo`name — resolution is always offline.

Safety guarantees
-----------------

[](#safety-guarantees)

The core is built to run on *any* environment without ever breaking the host application:

- **Per-collector fault isolation** — every collector runs inside its own guard. A throwing collector becomes a `failed` metric, a missing binary an `unsupported` metric. One bad collector can never abort the snapshot.
- **No shell interpolation** — commands run as argv arrays through a `ProcessRunner`(symfony/process when installed, a dependency-free `proc_open` runner otherwise). Every run is timeout-bounded and degrades gracefully where process functions are disabled.
- **Binary discovery without shelling out** — the `ExecutableFinder` scans `PATH` plus common sbin directories in pure PHP.
- **Zero runtime dependencies** — PHP &gt;= 8.0 and ext-json are all it needs.

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

[](#installation)

```
composer require mindtwo/base-monitoring
```

Quick start
-----------

[](#quick-start)

```
use Mindtwo\Monitoring\Monitor;

// A monitor with the full default collector catalog:
$monitor = Monitor::make(projectRoot: '/var/www/my-project');

$snapshot = $monitor->snapshot();

$snapshot->toArray(); // structured payload
$snapshot->toJson();  // wire format
```

### Pushing to the central endpoint

[](#pushing-to-the-central-endpoint)

```
use Mindtwo\Monitoring\Data\Credentials;
use Mindtwo\Monitoring\Monitor;
use Mindtwo\Monitoring\Transport\HttpTransport;

$transport = new HttpTransport(
    endpoint: 'https://monitoring.mindtwo.com/api/monitoring',
    credentials: new Credentials('prj_live_8f3a…', $secret),
);

$result = Monitor::make()->push($transport);

$result->success;    // bool — transports never throw
$result->statusCode; // ?int
$result->error;      // ?string
```

### Custom collectors

[](#custom-collectors)

A collector is one unit of data collection. Implement the contract (or extend `AbstractCollector`), return a `CollectionResult`, register it:

```
use Mindtwo\Monitoring\Collectors\AbstractCollector;
use Mindtwo\Monitoring\Data\CollectionResult;

final class DockerCollector extends AbstractCollector
{
    public function key(): string
    {
        return 'docker';
    }

    public function collect(): CollectionResult
    {
        return CollectionResult::ok($this->key(), ['version' => '26.1.0']);
    }
}

$monitor->register(new DockerCollector());          // throws on duplicate keys
$monitor->replace(new MyBetterDatabaseCollector()); // intentional override
$monitor->addCustomData('deployment', fn () => ['region' => 'eu-central-1']);
```

The snapshot payload
--------------------

[](#the-snapshot-payload)

`metrics` is an open map — each collector owns the shape under its key, so adding a collector adds a key and never requires a schema migration. Empty `custom_data` serializes as `{}`.

```
{
  "schema_version": "1.0",
  "collected_at": "2026-06-09T12:00:00+00:00",
  "environment": "production",
  "project_key": "prj_live_8f3a…",
  "source": { "type": "laravel", "package": "mindtwo/laravel-monitoring", "version": "1.2.0", "base_version": "1.0.3" },
  "metrics": {
    "os":  { "status": "ok", "technology": "ubuntu", "version": "22.04", "family": "Linux", "name": "Ubuntu 22.04.4 LTS", "kernel": "5.15.0-101-generic" },
    "php": { "status": "ok", "technology": "php", "version": "8.3.2", "sapi": "fpm-fcgi", "memory_limit": "256M" },
    "composer_audit": { "status": "warning", "advisories_count": 1, "advisories": [ { "package": "acme/http", "severity": "high", "cve": "CVE-2026-0001", "title": "…", "affected_versions": "
