Search by

1eonardo-dev / monitoring-client-legacy

1eonardo-dev

Legacy PHP client (PHP 5.6) for reporting events (crash/exception/log) to Monitoring Platform.

Package info

github.com/1eonardo-dev/monitoring-client-legacy

pkg:composer/1eonardo-dev/monitoring-client-legacy

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-09-20 19:33 UTC

This package is auto-updated.

Last update: 2026-09-20 19:59:58 UTC


README

A PHP 5.6 client for reporting events (crashes, exceptions, logs) to Monitoring Platform, for legacy projects that cannot yet run the modern package.

Packagist Version PHP Version License Downloads

Warning: PHP 5.6 has been end-of-life since 2018 and no longer receives security patches. This package exists only to provide backward compatibility for legacy projects. The recommended path is to migrate to PHP 7.4+ and use the 1eonardo-dev/monitoring-client package instead.

The two packages

If you are on PHP 7.4+, use the modern package instead:

Package PHP Framework adapters Type hints
1eonardo-dev/monitoring-client 7.4+ Laravel & Yii2 Yes
1eonardo-dev/monitoring-client-legacy 5.6+ None (pure PHP) No

Requirements

  • PHP 5.6 or later.

Installation

composer require 1eonardo-dev/monitoring-client-legacy

Quick start

use LeonardoDev\Monitoring\Legacy\MonitoringClient;

$monitoring = new MonitoringClient(
    'https://monitoring.your-company.com',
    'mp_...',
    'php',
    '1.0.0'
);

try {
    // your code
} catch (Exception $e) {
    $monitoring->captureException($e);
}

$monitoring->captureMessage('Something weird happened', 'warning');

Differences from the modern package

  • Uses Exception instead of Throwable (PHP 5 has no Throwable), so it cannot catch fatal PHP 7+ errors.
  • No scalar type hints or return types (docblocks only).
  • No framework adapters (pure PHP; no Laravel/Yii2 integration).
  • No mandatory Composer dependencies.

API

MonitoringClient

Method Description
captureException(Exception $e, array $context = array(), $level = null) Report an exception.
captureMessage($message, $level = 'info', array $context = array()) Report a log message.
captureEvent(Event $event) Report a custom event.
send(array $data) Low-level send with a raw payload.

DTOs

  • Event — value object for the event payload (type, level, message, platform, version, fingerprint, context).
  • Config — groups the connection parameters (baseUrl, apiKey, platform, version, timeoutSeconds, path).
use LeonardoDev\Monitoring\Legacy\Config;
use LeonardoDev\Monitoring\Legacy\Event;
use LeonardoDev\Monitoring\Legacy\MonitoringClient;

$client = MonitoringClient::fromConfig(new Config(
    'https://monitoring.your-company.com',
    'mp_...',
    'php',
    '1.0.0'
));

$client->captureEvent(new Event('custom', 'warning', 'something happened'));

Custom endpoint path

By default events are sent to {baseUrl}/api/v1/events. You can change the path via the path argument (or the path key in Config::fromArray):

$monitoring = new MonitoringClient(
    'https://monitoring.your-company.com',
    'mp_...',
    'php',
    '1.0.0',
    2,
    '/api/custom/ingest'
);

Custom transport

Implement LeonardoDev\Monitoring\Legacy\Transport\Transport to use your own HTTP client:

use LeonardoDev\Monitoring\Legacy\MonitoringClient;
use LeonardoDev\Monitoring\Legacy\Transport\Transport;

class MyTransport implements Transport
{
    public function send($url, $body, array $headers)
    {
        // ... return array('status' => int, 'body' => string), or null on failure.
    }
}

$client = new MonitoringClient(
    'https://monitoring.your-company.com',
    'mp_...',
    'php',
    null,
    2,
    '/api/v1/events',
    new MyTransport()
);

Tests

php tests/run.php

Changelog

See CHANGELOG.md.

License

MIT. See LICENSE.