Download the PHP package dennisvanbeersel/symfony-logger-client without Composer

On this page you can find all versions of the php package dennisvanbeersel/symfony-logger-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package symfony-logger-client

AppLogger Symfony Client

Symfony bundle for the AppLogger error tracking and application monitoring platform — automatic exception capture, log aggregation, a frontend JavaScript SDK, and non-blocking, resilient delivery.

Packagist Version Total Downloads PHP Version License


What is this?

This package is the Symfony client bundle for AppLogger (applogger.eu), an EU-hosted, privacy-first error tracking and application/log monitoring SaaS built for Symfony and PHP applications.

Once installed and enabled, the bundle wires itself into your application and ships telemetry to the AppLogger platform through three channels:

A central design goal of the bundle is that telemetry delivery never delays or breaks the host application. Sending is asynchronous and fire-and-forget by default, completes after the HTTP response has already been flushed to the user, and is guarded end-to-end so that no transport, encoding, or configuration failure propagates into your application's request handling.

The platform provides EU data residency, IP anonymization, PII scrubbing, and session-id hashing to support GDPR-conscious deployments.


Features


Requirements

The Composer-enforced runtime requirements are:

Requirement Constraint
PHP >=8.3
symfony/framework-bundle ^6.4 \|\| ^7.0 \|\| ^8.0
symfony/http-kernel ^6.4 \|\| ^7.0 \|\| ^8.0
symfony/monolog-bundle ^3.0 \|\| ^4.0
symfony/http-client ^6.4 \|\| ^7.0 \|\| ^8.0
symfony/uid ^6.4 \|\| ^7.0 \|\| ^8.0

Note: The JavaScript SDK is shipped pre-built in assets/dist/, so a Node.js toolchain is not required to use it. symfony/asset-mapper, symfony/twig-bundle, and twig/twig are development dependencies of this package — their absence in your application is tolerated, and the bundle remains fully functional. AssetMapper integration is wired automatically when AssetMapper is present; the Twig-based JS auto-injection is simply removed when Twig is not installed.


Installation

Install with Composer:

With Symfony Flex (recommended)

If your application uses Symfony Flex, the bundle is registered automatically and a Flex recipe is applied. The recipe:

The bundle ships inert after installation. Both PHP error tracking and the JavaScript SDK are gated on APPLICATION_LOGGER_ENABLED, which the recipe sets to false. To start sending telemetry, set your real credentials (preferably in .env.local) and flip the flag:

Two credentials, two purposes. The api_key (format: any string) is your server-side secret — it is sent from PHP via X-Api-Key and must never appear in browser-facing HTML. The publishable_key (format: pk_live_…) is a write-only, browser-safe key — it is embedded in the auto-injected JS SDK and used exclusively for browser JS error ingest at /api/v1/js-errors via X-Publishable-Key. Obtain the publishable key from your project's Settings > Publishable Keys page on AppLogger.

The recipe also defaults release to %env(default::APP_VERSION)%, environment to %kernel.environment%, and debug to %kernel.debug%.

Without Flex (manual setup)

  1. Register the bundle in config/bundles.php:

  2. Create config/packages/application_logger.yaml. A minimal configuration needs a DSN, a server-side API key, and — to enable browser JS error tracking — a publishable key:

  3. Add the corresponding environment variables to .env / .env.local and clear the cache:

The bundle does not require a Monolog handler to be declared by hand. It prepends its own service-type Monolog handler automatically on the channels !event, !request, and !php (those framework channels are excluded to avoid double-recording uncaught exceptions, which are already handled by the exception subscriber).


Configuration

The configuration root key is application_logger. The DSN and API key are the only values required to start sending; everything else has a sensible default.

v2.0 note: The bundle is now a thin Symfony adapter over applogger/sdk-core. Error capture routes through the SDK Hub; log aggregation routes through LogClient. Several configuration keys that were previously active (endpoint_path, log_path, log_batch_size, max_log_buffer, retry_attempts, async, circuit_breaker.enabled) are now deprecated no-ops — they are accepted without error but have no effect, and will be removed in a future major version. Remove them from your config to silence deprecation notices.

DSN and authentication

The DSN identifies your project endpoint and has the form:

The client-internal parser validates that a project-id path segment exists. The API key is not embedded in the DSN — it is sent separately in the X-Api-Key request header.

Authentication summary:

Channel Credential Header Destination
Error & session tracking (server-side PHP) api_key — secret, server only X-Api-Key: <api_key> Platform API host (from the DSN)
Log aggregation (server-side PHP) log_token (sk_log_…) — secret, server only X-Api-Key: <log_token> log_endpoint (the AppLogger log collector)
Browser JS error ingest publishable_key (pk_live_…) — write-only, safe to embed X-Publishable-Key: <publishable_key> /api/v1/js-errors on the platform API host

Inertness rules:

Core options

Option Type Default Description
dsn string '' Project endpoint URL https://host/project-id. Contains no credentials — safe to appear in browser JS config (the JS SDK also receives it as the dsn prop). Empty = inert. Deliberately not required, so a skipped Flex recipe never breaks cache:clear.
api_key string '' Server-side secret. Sent as X-Api-Key from PHP. Empty = inert. Never expose to the browser.
publishable_key string '' Browser-safe write-only key (pk_live_…). Embedded in the auto-injected JS SDK; sent as X-Publishable-Key for browser JS error ingest at /api/v1/js-errors. Obtain from your project's Settings > Publishable Keys page. Empty = JS SDK not injected.
enabled bool true Global error-tracking enable.
release string null Version / release identifier.
environment string 'production' Environment name reported with telemetry.
error_tracking_enabled bool true Capture and ship exceptions/errors. Set false to run log-aggregation only.
log_aggregation_enabled bool true Buffer and ship non-exception log records. Set false to run error-tracking only.
endpoint_path string /api/v1/errors (Deprecated in v2.0 — no-op; the SDK core owns this.)

Log aggregation

Option Type Default Description
log_endpoint string null Collector base URL, e.g. https://<slug>.logs.applogger.eu. null = aggregation off.
log_token string null Log token (sk_log_…), sent as X-Api-Key to the collector.
excluded_channels array ['http_client','console','deprecation','doctrine'] Monolog channels excluded from log aggregation (beyond the always-excluded framework channels). Set to [] to aggregate all channels.
log_path string /v1/logs (Deprecated in v2.0 — no-op; the SDK core owns this.)
log_batch_size int 50 (Deprecated in v2.0 — no-op; the SDK core owns this.)
max_log_buffer int 1000 (Deprecated in v2.0 — no-op; the SDK core owns this.)

Performance & resilience

Option Type Default Description
timeout float 2.0 Request timeout in seconds (min 0.5, max 5.0).
flush_budget float 2.0 Wall-clock cap (s) on the post-response telemetry drain. Effective cap = min(timeout, flush_budget). Lower to 0.5 to harden FrankenPHP worker pools against a slow collector.
debug bool false Internal PHP debug logging.
retry_attempts int 0 (Deprecated in v2.0 — no-op; the SDK core owns this.)
async bool true (Deprecated in v2.0 — no-op; the SDK core owns this.)

Circuit breaker (circuit_breaker)

The circuit breaker is owned by applogger/sdk-core in v2.0 and is always-on. The enabled key is accepted but has no effect.

Option Type Default Description
enabled bool true (Deprecated in v2.0 — no-op; the SDK core's circuit breaker is always-on.)
failure_threshold int 5 Failures before the circuit opens (min 1).
timeout int 60 Seconds the circuit stays open (min 10, max 300).
half_open_attempts int 1 Trial requests allowed while half-open (min 1).

Capture

Option Type Default Description
capture_level string error Minimum Monolog level routed by the handler (debug–emergency). An invalid literal falls back to error at runtime rather than throwing.
scrub_fields array see below Field names redacted before sending (kept in sync with the JS list).
max_breadcrumbs int 50 Maximum breadcrumbs retained (min 10, max 100).

JavaScript (javascript)

Option Type Default Description
enabled bool true Enable the frontend SDK.
auto_inject bool true Automatically inject the SDK into HTML responses.
debug bool false SDK debug logging.
environment string null Falls back to the root environment.
release string null Falls back to the root release.
scrub_fields array [] Merged (deduplicated) with the root scrub_fields.

Session tracking (session_tracking)

Option Type Default Description
enabled bool true Required for session replay.
track_page_views bool true Record page-view events.
idle_timeout int 1800 Idle timeout in seconds (min 300, max 7200).
ignored_routes array ['_profiler', '_wdt'] Routes excluded from tracking.
ignored_paths array ['/api/', '/_fragment'] Path prefixes excluded from tracking.

Session replay (session_replay)

These values are forwarded to the JavaScript SDK. Replay is error-triggered only (never continuous). See Session replay for the important note on default state.

Option Type Default Description
enabled bool true Error-triggered replay enable (see note below).
buffer_before_error_seconds int 30 Seconds buffered before an error (min 5, max 60).
buffer_before_error_clicks int 10 Clicks buffered before an error (min 1, max 15).
buffer_after_error_seconds int 30 Seconds buffered after an error (min 5, max 60).
buffer_after_error_clicks int 10 Clicks buffered after an error (min 1, max 15).
snapshot_throttle_ms int 1000 DOM snapshot throttle (min 500, max 5000).
click_debounce_ms int 1000 Click debounce (min 100, max 5000).
max_snapshot_size int 1048576 Max snapshot size in bytes (min 102400, max 5242880).
session_timeout_minutes int 30 Replay session timeout (min 5, max 120).
max_buffer_size_mb int 5 Max replay buffer size in MB (min 1, max 20).
expose_api bool true Expose the JS enable/disable/isEnabled runtime API.

Realistic example


Usage

Automatic exception capture (zero-config)

Once the bundle is enabled with a valid DSN and API key, uncaught exceptions are captured automatically. The exception subscriber listens on kernel.exception at a low priority (-100, after the framework's own handlers), extracts the HTTP status code (the status of an HttpExceptionInterface, otherwise 500), attaches exception_class and exception_code tags plus a breadcrumb, and sends the error payload. The subscriber is wrapped in its own try/catch and never interferes with your application's exception handling.

No code changes are needed for this.

Manual capture via Monolog

Because the bundle auto-registers a Monolog handler, the most natural way to record events from your own code is to log through Monolog. The handler routes records by content:

Log aggregation via Monolog

Records without an exception that meet the capture_level threshold are buffered and shipped to the log collector in batches:

Each record is converted into a log entry with an RFC3339 timestamp, an RFC5424 severity keyword (debug, info, notice, warning, error, critical, alert, emergency), the Monolog channel as the application name, the environment, and a scrubbed, flattened context map. Entries are sent to POST <log_endpoint><log_path> (or the /batch variant for batches); a successful ingestion returns HTTP 202 Accepted. If no log_endpoint / log_token is configured, log aggregation is silently skipped.

Smoke-test the log channel

Verify collector credentials without booting Symfony:

Or, with the bundle installed: php bin/console application-logger:test.

LogEntry fields: timestamp (RFC3339), severity (syslog keyword), message (≤8000), app_name (≤255), environment, context (map of string→string).

JavaScript SDK

The bundled SDK uses the publishable key (pk_live_…) for browser error ingest — never the secret api_key. The publishable key is write-only and safe to embed in HTML. Obtain it from your project's Settings > Publishable Keys page on AppLogger, then set it in .env.local:

and declare it in config/packages/application_logger.yaml:

When publishable_key is non-empty and javascript.enabled is true (the default), the bundle auto-injects the SDK into eligible HTML responses. The SDK sends browser errors to /api/v1/js-errors via X-Publishable-Key.

With javascript.auto_inject enabled (the default), injection is automatic for main requests with a text/html content type, a status below 400, a </body> tag, and a body under 1 MiB. Error pages (4xx/5xx) are deliberately skipped.

If you prefer to place the SDK yourself (and Twig is available), disable auto_inject and call the Twig function just before </body>:

At runtime the SDK is exposed as window.appLogger. It automatically captures window error events, unhandled promise rejections, failed fetch/HTTP requests, and console.error() breadcrumbs. When expose_api is enabled (the default), you can also report manually:

The SDK is resilient on the client side too: a sessionStorage-backed circuit breaker (default threshold 5, 60s open window), a localStorage offline queue (default 50 events, 24h max age), token-bucket rate limiting (default burst of 10, refilling at ~10/minute — 0.167 tokens/second), and deduplication (default 5s window). On page close it uses the Beacon API to flush queued events. Breadcrumbs are capped at 50 by default.

Session replay (opt-in)

Session replay is error-triggered only — it never records continuously. When enabled, the SDK buffers a window of DOM snapshots and interactions before and after an error and sends that data together with the error payload (not as a separate request). Cross-page continuity is maintained via localStorage.

Session tracking (session_tracking.enabled) must be on for replay to function.

Important — default state: Replay is an opt-in feature. The JavaScript SDK itself defaults sessionReplayEnabled to false, while the bundle's PHP session_replay.enabled config node defaults to true; the effective value forwarded to the SDK is whatever the PHP configuration / Twig integration provides. Treat replay as opt-in and error-triggered, and explicitly confirm session_replay.enabled in your configuration to match your intended behavior. When expose_api is true, replay can also be toggled at runtime:

The non-blocking, never-throws guarantee

By default (async: true) telemetry is dispatched fire-and-forget and completed after the HTTP response has been flushed to the client:

The single dispatch envelope is guarded throughout: the global kill-switch, JSON encoding, the circuit breaker, and the transport itself are all wrapped so failures are recorded internally and never thrown into your application. The only intentional exceptions are at construction time (an out-of-range timeout, or a non-empty but malformed DSN), which surface genuine misconfiguration early.


Privacy & GDPR

The bundle is designed to scrub sensitive data on your host, before anything is transmitted:

The AppLogger platform itself is EU-hosted with EU data residency. As with any monitoring tool, review what your application logs and adjust scrub_fields to match your data-protection obligations.


The AppLogger.eu platform

AppLogger is an EU-hosted, privacy-first error tracking and application/log monitoring SaaS built on a Symfony stack:

Getting a DSN and tokens

  1. Sign up at applogger.eu.
  2. Create a project to obtain its DSN and API key (server-side; used for error and session tracking from PHP).
  3. For browser JS error tracking, obtain the project's Publishable Key (pk_live_…) from Settings > Publishable Keys. This is safe to embed in HTML.
  4. For log aggregation, obtain the project's log endpoint and log token (sk_log_…).
  5. Put these values in your .env.local and set APPLICATION_LOGGER_ENABLED=true.

Links


Contributing

Contributions are welcome. Please open issues and pull requests on the package repository.

The project follows PSR-12 with declare(strict_types=1) and is checked at PHPStan level 6. Convenience Composer scripts are provided:

Please ensure composer lint and composer test pass before submitting a pull request.


Security

If you discover a security vulnerability, please report it responsibly rather than opening a public issue. Use the security advisory channel on the package repository so it can be addressed before public disclosure.


License

Released under the MIT License.

Authored by Dennis Van Beersel — applogger.eu.


All versions of symfony-logger-client with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
applogger/sdk-core Version ^1.0
monolog/monolog Version ^3.0
symfony/framework-bundle Version ^6.4|^7.0|^8.0
symfony/http-kernel Version ^6.4|^7.0|^8.0
symfony/monolog-bundle Version ^3.0|^4.0
symfony/http-client Version ^6.4|^7.0|^8.0
symfony/uid Version ^6.4|^7.0|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dennisvanbeersel/symfony-logger-client contains the following files

Loading the files please wait ...