Download the PHP package koriym/semantic-logger without Composer

On this page you can find all versions of the php package koriym/semantic-logger. 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 semantic-logger

Koriym.SemanticLogger

Type-safe semantic logging for hierarchical application workflows with tree-shaped JSON output.

Koriym.SemanticLogger records three kinds of facts as structured JSON:

Each entry carries a schema URL and typed context data, so logs stay machine-readable and can be validated, rendered, and inspected without depending on free-form log messages.

The public log contract is structural: everything that happened inside an open is in its children, in the order it was recorded, and its matching close is nested on it. Once serialized to JSON, normal operation results are read from paths such as entries[0].close — not from a separate top-level close list.

Installation

Core Model

Semantic logs are built from matching open / close pairs plus optional events:

This gives you:

Optional RFC 8288 links can be attached at flush time when you want to point to related resources such as source code, schemas, or external specs.

Quick Start

1. Define Context Classes

The recorded context data is the JSON representation of the context: public properties by default, or the jsonSerialize() result when the context implements JsonSerializable and that result is a string-keyed array or an object. Other return shapes fall back to public properties. A context that cannot be serialized is replaced by a core-owned placeholder entry, so one bad context never loses the session.

2. Log a Workflow

3. Output Shape

flush() returns a LogJson object. Its public JSON is a tree in record order: entries lists what happened at the root, each entry has a kind of open or event, and every open carries its own children (events and nested opens, in the order they were recorded) plus its matching close. Reading the document top to bottom is reading the timeline.

close is absent while an open is still unclosed. A top-level close list appears only for orphan closes (a close whose openId matches no open in the log, or a second close for an open that is already closed); it is diagnostic output, not part of the normal tree.

The Logger Never Throws

SemanticLogger never throws — not on serialization failures, not on protocol misuse, not on empty sessions. Failures become data: core-owned diagnostic entries in the log itself.

Quality gates live on the reading side: the validator lists diagnostics with their own severity, and --fail-on-diagnostics lets CI turn their presence into a failing build.

Note the layer boundary: diagnostics cover the logger's own recording operations. Detecting that a cache server or database is down is monitoring's job, not this library's — record what matters to your domain as your own context types.

Open / Close Ordering

open and close must be paired in LIFO order. The logger never throws on violations — it records them as semantic_logger_error diagnostic entries with one of these kind values:

Wrap work in try/finally so close() always runs — not because the logger throws, but because your log should reflect what actually happened.

Try It

A runnable end-to-end example lives under demo/ (see demo/run.php, demo/e-commerce.php). composer demo runs it with XHProf + Xdebug enabled, validates the output, and renders it with stree.

Development Logs

Use DevLogger to write logs to disk during development:

Each call writes a file named semantic-dev-<timestamp>-<pid>-<uniqid>.json (microsecond timestamp, PID, and uniqid() suffix) to the given directory, or to sys_get_temp_dir() when no directory is passed.

DevLogger writes the same public tree JSON shape returned by flush(), which works naturally with stree.

Profiling (XHProf / Xdebug)

Wrap a SemanticLogger in DevSemanticLogger to attach per-operation profiler artifacts to each matched close entry:

When XHProf and/or Xdebug are enabled, each close in the tree gains a profile object with wallTime plus xhprofProfile / xdebugTrace segments captured while that operation was active:

Segments are attributed only to the operation they ran inside — the parent's profile pauses while a child is open. No extensions required to use the logger itself; DevSemanticLogger simply skips profile attachment when XHProf / Xdebug are not loaded.

Validate Semantic Logs

The envelope (root tree) is always validated against the bundled docs/schemas/semantic-log.json shipped in the composer dist. You supply a schema directory for your own context schemas — the CLI defaults to ./schemas/ when the second argument is omitted.

Validation checks:

Pass --fail-on-diagnostics to exit non-zero when the log contains logger-recorded diagnostic entries — the recommended CI gate:

Semantic Tree Visualizer

vendor/bin/stree renders semantic logs as a readable tree:

Options

Option Short Description
--threshold=T -t Time threshold filter such as 10ms or 0.5s
--lines=N -l Maximum lines for multi-line data (0 means no limit)
--full -f Show the full tree
--values -V Let registered formatters show values instead of only keys
--json Pretty-print raw JSON
--help -h Display help

Rendering in process

stree is a thin CLI over the same renderer you can call directly. LogJson::render() takes a LogRendererInterface and hands the log to it (double dispatch), so the log never needs to know the output format — you swap the renderer instead:

This keeps the tree compact for both humans (visual parent/child structure) and AI consumers (far fewer tokens than the raw JSON). Implement LogRendererInterface to add your own output format (e.g. Markdown or Mermaid) without changing the logger.

Use Cases

Documentation


All versions of semantic-logger with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
justinrainbow/json-schema Version ^6.4
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 koriym/semantic-logger contains the following files

Loading the files please wait ...