Introduction
The Lescopr PHP SDK integrates seamlessly with Laravel via a Service Provider that is registered automatically through Composer's package auto-discovery.
Once installed, all Log::error(), Log::warning() and unhandled exceptions are captured and forwarded in real-time to your Lescopr dashboard.
The package is available on Packagist and is compatible with Laravel 8+ and PHP 7.4+.
Requirements
Erreur de chargement
Installation
Install the package via Composer:
The Service Provider is registered automatically via Laravel's package auto-discovery — no manual registration needed.
Optionally, publish the config file to customise defaults:
composer require lescopr/lescopr-phpphp artisan vendor:publish --tag=lescopr-configConfiguration
Add your keys to your .env file:
Then add the Lescopr channel to your logging stack in config/logging.php:
Available options:
sdk_key— Your Lescopr SDK key (required)api_key— Your Lescopr API key (required)environment— The current environment (production,staging,development)LESCOPR_DEBUG=true— Enables verbose output to.lescopr.log
LESCOPR_SDK_KEY=lsk_xxxx
LESCOPR_API_KEY=lak_xxxx
LESCOPR_ENVIRONMENT=production'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'lescopr'],
],
'lescopr' => [
'driver' => 'monolog',
'handler' => \Lescopr\Integrations\Laravel\Logging\LescoprMonologHandler::class,
'handler_with' => [
'sdk' => app(\Lescopr\Core\Lescopr::class),
],
],
],Usage
Once configured, all log calls are forwarded automatically to Lescopr via the Monolog handler:
Unhandled exceptions are also captured automatically via the exception handler decorator bundled with the LescoprServiceProvider.
You can also log manually anywhere in your application:
use Illuminate\Support\Facades\Log;
Log::info('Order placed', ['order_id' => $order->id]);
Log::error('Payment failed', ['reason' => $e->getMessage()]);try {
$this->processPayment($order);
} catch (\Throwable $e) {
app(\Lescopr\Core\Lescopr::class)->report($e);
throw $e;
}Advanced
Initialising via CLI
You can initialise the SDK from the command line. This detects your framework, registers the project, writes .lescopr.json, and starts the background daemon:
Daemon management
The background daemon flushes your log queue every 5 seconds via HTTPS — completely non-blocking:
Environment variables
LESCOPR_SDK_KEY— SDK key (overrides.lescopr.json)LESCOPR_API_KEY— API keyLESCOPR_ENVIRONMENT—developmentorproductionLESCOPR_DAEMON_MODE=true— Prevents the SDK from forking inside its own daemonLESCOPR_DEBUG=true— Enables verbose output to.lescopr.log
./vendor/bin/lescopr init --sdk-key YOUR_SDK_KEY./vendor/bin/lescopr start
./vendor/bin/lescopr status
./vendor/bin/lescopr stop