SDKs

PHP SDK

Install the Logdash PHP SDK, send your first log and your first metric.

Install the package, add your ingest key and the first log lands in the dashboard within a second. Everything below is copied from the PHP SDK README.

Install

composer require logdash/php-sdk

Initialise

Copy the ingest key from your domain's settings in Logdash and keep it in an environment variable. The key identifies the domain the data lands in, and app names the program that sends, such as api or worker. See Apps.

<?php

require_once 'vendor/autoload.php';

use Logdash\Logdash;

$logdash = Logdash::create([
    'apiKey' => $_ENV['LOGDASH_API_KEY'] ?? '',
    'app' => 'api'
]);

$logger = $logdash->logger();
$metrics = $logdash->metrics();

Send a log

$logger->error('Application error occurred');
$logger->warn('This is a warning message');
$logger->info('User logged in successfully');

Send a metric

Metrics are named numbers. Set one to an absolute value or mutate it by a delta, and Logdash charts the history.

$metrics->set('active_users', 150);
$metrics->mutate('login_count', 1); // Increment by 1
$metrics->mutate('error_count', -1); // Decrement by 1

Send an event

Events go to web analytics of the domain, next to the custom events of your website, with the same rules for names and properties.

$logdash->track('agent_run', [
    'agent' => 'support',
    'steps' => 4,
    'success' => true,
], $user->id);

Flush before exit

The SDK sends in the background. In a short-lived process, such as a cron job, a CLI or a serverless function, send what is still queued before the process exits.

$logdash->flush();

Works with

  • Laravel
  • Symfony
  • Slim
  • WordPress
  • Plain PHP

FAQ

What happens if Logdash is unreachable?
Nothing breaks. The SDK is non-blocking and fails silently in production, local logging keeps working, and API errors are only surfaced when you pass verbose => true.
How do I use it in Laravel?
Bind it as a singleton in a service provider with Logdash::create([...]), then call app("logdash")->logger(). Symfony gets the same object through a services.yaml factory.
Which PHP version does it need?
PHP 8.1 or higher, tested on 8.1, 8.2 and 8.3. Composer pulls in the Guzzle HTTP client for you.

Copied from the php-sdk README at 84b58de on 2026-11-09.