PHPackages                             lescopr/lescopr-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. lescopr/lescopr-php

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

lescopr/lescopr-php
===================

Lescopr PHP SDK - Zero-configuration monitoring for PHP applications. Auto-captures logs, errors and metrics from Laravel, Symfony and vanilla PHP projects.

v1.1.1(2w ago)00MITPHPPHP ^7.4 || ^8.0CI passing

Since Apr 21Pushed 2w agoCompare

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

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

Lescopr PHP SDK
===============

[](#lescopr-php-sdk)

[![Packagist Version](https://camo.githubusercontent.com/d6dc97137f8ad146dec8d63c991b70e8f7f5ddcb6e9e224c5366ab9b7dc6ba09/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6573636f70722f6c6573636f70722d7068702e737667)](https://packagist.org/packages/lescopr/lescopr-php)[![Packagist Downloads](https://camo.githubusercontent.com/1bbdd33617f21015a404b7b85eb35c8177bea2378c41f920722c752574fcece0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6573636f70722f6c6573636f70722d7068702e737667)](https://packagist.org/packages/lescopr/lescopr-php)[![PHP versions](https://camo.githubusercontent.com/09e544e56c5ae05822c243fa4540e752fd55dd4a897f1aa9283b985b018f5d67/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c6573636f70722f6c6573636f70722d7068702e737667)](https://packagist.org/packages/lescopr/lescopr-php)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)

**Lescopr** is a zero-configuration PHP monitoring SDK that automatically captures logs, errors, and exceptions from any PHP project and streams them in real-time to the [Lescopr dashboard](https://app.lescopr.com).

Works out of the box with **Laravel**, **Symfony**, and **vanilla PHP / custom OOP** projects.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Framework Integration](#framework-integration)
    - [Laravel](#laravel)
    - [Symfony](#symfony)
    - [Vanilla PHP / POO](#vanilla-php--poo)
- [Architecture](#architecture)
- [CLI Reference](#cli-reference)
- [Advanced Configuration](#advanced-configuration)
- [Packagist](#packagist)
- [License](#license)

---

Features
--------

[](#features)

- ✅ **Automatic error capture** — hooks into `set_error_handler`, `set_exception_handler`, `register_shutdown_function`
- ✅ **Framework auto-detection** — detects Laravel, Symfony, Lumen, Slim, and vanilla PHP from `composer.json`
- ✅ **Monolog integration** — drop-in handler for Laravel and Symfony
- ✅ **Background daemon** — runs as a `pcntl_fork` process, completely non-blocking
- ✅ **HTTP batch transport** — logs are batched and flushed every 5 seconds via HTTPS
- ✅ **Zero configuration** — a single CLI command is enough to get started
- ✅ **Works everywhere** — Laravel, Symfony, Lumen, Slim, scripts, custom OOP

---

Requirements
------------

[](#requirements)

RequirementVersionPHP≥ 7.4Composer≥ 2.0`guzzlehttp/guzzle``^6.5 || ^7.0``symfony/console``^4.4 || ^5.0 || ^6.0 || ^7.0``ext-json`bundled with PHP`ext-pcntl`Recommended (for daemon)`ext-posix`Recommended (for daemon)`ext-openssl`Recommended (for HTTPS)> **Note:** `ext-pcntl` is not available on Windows. On those environments the SDK operates in direct HTTP mode (no background daemon).

---

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

[](#installation)

```
composer require lescopr/lescopr-php
```

---

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

[](#quick-start)

**Step 1 — Initialise the SDK in your project directory:**

```
./vendor/bin/lescopr init --sdk-key YOUR_SDK_KEY
```

This auto-detects your framework, registers the project with the Lescopr API, writes `.lescopr.json`, and starts the background daemon.

**Step 2 — Integrate into your application** (see [Framework Integration](#framework-integration) below).

**That's it.** All logs and exceptions are forwarded to the Lescopr dashboard automatically.

---

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

[](#framework-integration)

### Laravel

[](#laravel)

The SDK registers automatically via Composer's package auto-discovery. No manual registration needed.

**Publish the config (optional):**

```
php artisan vendor:publish --tag=lescopr-config
```

**Add the Lescopr channel to your logging stack in `config/logging.php`:**

```
'channels' => [
    'stack' => [
        'driver'   => 'stack',
        'channels' => ['single', 'lescopr'],  // ← add 'lescopr'
    ],

    'lescopr' => [
        'driver'  => 'monolog',
        'handler' => \Lescopr\Integrations\Laravel\Logging\LescoprMonologHandler::class,
        'handler_with' => [
            'sdk' => app(\Lescopr\Core\Lescopr::class),
        ],
    ],
],
```

All `Log::info(...)`, `Log::error(...)` etc. calls are automatically forwarded to Lescopr.

**Exceptions** are captured automatically via the exception handler decorator bundled with the ServiceProvider.

**Environment variables (`.env`):**

```
LESCOPR_SDK_KEY=lsk_xxxx
LESCOPR_API_KEY=lak_xxxx
LESCOPR_ENVIRONMENT=production
```

---

### Symfony

[](#symfony)

**Register the bundle in `config/bundles.php`:**

```
return [
    // ... other bundles
    Lescopr\Integrations\Symfony\LescoprBundle::class => ['all' => true],
];
```

**Wire the Monolog handler in `config/packages/monolog.yaml`:**

```
monolog:
  handlers:
    lescopr:
      type:     service
      id:       Lescopr\Integrations\Symfony\LescoprMonologHandler
      channels: ['!event', '!doctrine']
```

**Register services in `config/services.yaml`:**

```
services:
  Lescopr\Core\Lescopr:
    factory: ['Lescopr\Core\Lescopr', 'fromConfig']
    public: true

  Lescopr\Integrations\Symfony\LescoprMonologHandler:
    arguments: ['@Lescopr\Core\Lescopr']

  Lescopr\Integrations\Symfony\EventSubscriber\KernelExceptionSubscriber:
    arguments: ['@Lescopr\Core\Lescopr']
    tags:
      - { name: kernel.event_subscriber }
```

Kernel exceptions are automatically captured via `KernelExceptionSubscriber`.

---

### Vanilla PHP / POO

[](#vanilla-php--poo)

Add **one line** at the top of your entry point (`index.php` / `bootstrap.php`):

```
