Download the PHP package gilbitron/canonical-context-logging without Composer

On this page you can find all versions of the php package gilbitron/canonical-context-logging. 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 canonical-context-logging

Canonical Context Logging - PHP SDK

PHP SDK for Canonical Context Logging - structured JSON logs with one wide event per request.

Overview

This package implements the Canonical Context Logging pattern:

  1. Emit structured logs only - JSON, consistent keys, no free-text messages
  2. Log one "wide event" per request - Capture all context in a single final log entry
  3. Accumulate context via middleware - Build an event object at request start, enrich it throughout execution, emit once at the end
  4. Prefer context over volume - Fewer logs, richer data
  5. Tail-sample aggressively - Always keep errors + slow requests; sample the rest
  6. Store logs as queryable data - Columnar DB + SQL > grep
  7. OTel is transport, not design - You decide what to log; business context is your job

Requirements

Installation

Quick Start

Basic Usage (Framework-Agnostic)

With Error Handling

Configuration

Exporter Options

Console Exporter (Development)

For local development, you can use the console exporter to output logs to stdout/stderr:

OTLP Exporter (Production)

The OTLP exporter uses the official OpenTelemetry SDK and reads configuration from environment variables:

Environment Variables:

The exporter reads standard OpenTelemetry environment variables:

Example:

File Exporter

Write logs to a file in JSONL format (one JSON object per line):

The FileExporter automatically creates the directory structure if it doesn't exist and appends each log entry as a new line (JSONL format).

Custom Exporter

Implement ExporterInterface to create your own exporter:

Logger Configuration

Tail-Sampling Rules:

Context Storage

Singleton Storage (Framework-Agnostic)

Container Storage (Framework-Specific)

For framework integration, create a custom storage implementation that uses your framework's container.

EventContext API

The EventContext class accumulates all context for a single request:

Log Output Format

The structured log output follows this schema:

Best Practices

  1. One log per request - Use middleware to emit a single log at request end
  2. Accumulate context - Add business context throughout request execution
  3. Structured data only - No free-text messages, use consistent keys
  4. Tail-sample - Configure sampling to reduce volume while keeping errors and slow requests
  5. Business context - Include user, org, plan, feature flags, etc. - anything that helps answer questions
  6. Error handling - Always capture exceptions in context, even if you re-throw them

License

MIT


All versions of canonical-context-logging with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
open-telemetry/sdk Version ^1.0
open-telemetry/exporter-otlp Version ^1.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 gilbitron/canonical-context-logging contains the following files

Loading the files please wait ...