Download the PHP package adelinferaru/nestedflowtracker without Composer

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

NestedFlowTracker

CI Latest Version on Packagist Total Downloads PHP Version

adelinferaru.github.io/nestedflowtracker

A zero-infra flow tracer. Wrap any block of code in a span; it gets timed and stored as a tree in your own database, with nested sub-operations recorded as children. A single flow can span multiple applications via a shared trace_id.

No collectors, no external backend — unlike OpenTelemetry you need no infrastructure, and unlike Telescope it traces your business flows (not framework internals) and works in production.

Requires PHP 8.1+. As of 3.0 the package is split into a framework-agnostic Core (only PSR-3/14/17/18 dependencies) and a Laravel adapter (auto-discovered on Laravel 10, 11, 12, or 13; L13 needs PHP 8.3+). Use either side independently.

Installation

Publish and run the migration:

Optionally publish the config:

Upgrading from 2.x

3.0 is namespace-only: behaviour, config keys, env vars, the flow_spans schema and the artisan commands are all unchanged. composer update plus a search-and-replace on imports usually does it. The full namespace table lives in changelog.md. The most common moves:

Usage

The recommended API is span(): it opens a span, runs your callback, and closes it automatically — even if the callback throws. It returns the callback's value untouched.

This records a tree:

You can also use the flow() helper or resolve the service from the container:

Without Laravel

Construct Core\FlowTracker yourself and drive it directly. Any PSR-3 logger / PSR-14 dispatcher work; the package ships PDO-backed storage drivers, a PSR-18 OTLP exporter, and a null driver.

Other Core drivers: LogDriver(LoggerInterface) (PSR-3), NullDriver, and OtelDriver (wraps the PSR-18/17 Core\Otel\OtelExporter). All implement Core\Drivers\SpanDriver — bring your own if you want a different backend.

A complete runnable round trip — trace a flow (including a failed span), store it in SQLite, read the tree back with plain SQL — lives in examples/plain-php.php:

Enriching a span

The open span is passed to your callback:

Manual spans

When you cannot wrap the work in a closure, open and close spans manually (LIFO — the innermost open span is closed first):

Across applications (W3C Trace Context)

Flows propagate across services via the standard traceparent header (our trace_id is already a 32-hex W3C trace id).

Outbound — add the current trace to an HTTP client call:

Inbound — with flow.auto.http enabled, an incoming traceparent is read automatically and the request's root span continues the upstream trace. Doing it manually:

Artisan commands

Events

SpanStarted and SpanFinished are dispatched as spans open and close, so you can react to them (e.g. log slow spans):

Automatic instrumentation

Opt in to record spans with zero manual calls:

Both default to off, so installing the package never silently writes spans.

The #[Trace] attribute

Annotate a route action (or a whole controller) or a queued job to wrap it in a span — the attribute is the opt-in, no other code or config:

Viewer

A small built-in UI to browse recorded flows as timed trees — no build step, no assets to compile. Enable it and visit /flow:

Access control: the viewer is reachable automatically in the local environment. In any other environment you must define a viewFlow gate to grant access:

Publish the views to customize them: php artisan vendor:publish --tag="flow-views".

JSON API

The viewer also exposes a read API (same enable flag + viewFlow gate):

For token-based/stateless API clients, set flow.viewer.middleware to ['api'].

Storage drivers

Choose where finished spans go with flow.driver:

Driver Stores spans as Viewer / flow:*
database (default) a tree in your database ✅
log structured log lines (flow.log.channel) —
null discarded (API stays on) —
otel sent straight to an OTLP collector, no DB —

The viewer, the artisan commands, and the flow.otel export below are database-only features (they read from the flow_spans table). The log, null, and otel drivers are emit-only.

OpenTelemetry export

Already running an OpenTelemetry Collector, Jaeger, or Grafana Tempo? Ship completed flows there too — no OTel SDK required, we just POST OTLP-JSON. When a flow's root span closes, the whole trace is exported on a queue.

This is the database path: spans are stored and exported. If you don't want to store them at all, use the otel storage driver above (FLOW_DRIVER=otel), which sends spans straight to the collector with no database.

Upgrading from an earlier 2.x? Re-publish and run migrations after upgrading: php artisan vendor:publish --tag="flow-migrations" && php artisan migrate. Run a queue worker so exports happen off the request.

Configuration

Env Config key Default Description
FLOW_ENABLED flow.enabled true Master switch. When off, span() runs your callback transparently and stores nothing.
FLOW_COMPONENT flow.component app Name of this application/service, stored on every span.
FLOW_DRIVER flow.driver database Storage driver: database / log / null / otel.
FLOW_BUFFER flow.buffer false Buffer a flow and bulk-insert on completion (database driver).
FLOW_LOG_CHANNEL flow.log.channel null Log channel for the log driver (null = default).
FLOW_CONNECTION flow.connection null Connection for the flow_spans table (null = default).
FLOW_AUTO_HTTP flow.auto.http false Auto root span per HTTP request.
FLOW_AUTO_QUEUE flow.auto.queue false Auto root span per queued job.
FLOW_ATTRIBUTES flow.attributes true Honor the #[Trace] attribute on actions/jobs.
FLOW_VIEWER flow.viewer.enabled false Register the built-in viewer routes.
FLOW_VIEWER_PATH flow.viewer.path flow URL prefix for the viewer.
FLOW_OTEL_ENABLED flow.otel.enabled false Export completed flows to an OTLP/HTTP collector.
FLOW_OTEL_ENDPOINT flow.otel.endpoint null Collector base URL (spans go to {endpoint}/v1/traces).

Performance

Tracking costs nothing when off and little when on — measure it for your setup:

Indicative per-span overhead (300 flows × 6 spans, in-memory SQLite — your database and hardware will differ, the database figure especially):

Scenario µs / span
disabled (flow.enabled=false) ~2
null driver (tracking, no storage) ~60
database driver (immediate) ~1030
database driver (flow.buffer=true) ~125

The immediate database cost is dominated by the two writes per span. Buffered mode (FLOW_BUFFER=true) holds a whole flow in memory and bulk-inserts it in a single query when the flow completes — roughly 8× faster here. The trade-off: spans are only persisted once the flow completes (a crash mid-flow loses it), so it's off by default. flow_spans is indexed on trace_id, span_id, component, status, and created_at.

Testing

Credits

License

MIT. Please see the license file for more information.


All versions of nestedflowtracker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.0
laravel/framework Version ^10.0|^11.0|^12.0|^13.0
psr/event-dispatcher Version ^1.0
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.0|^2.0
psr/log Version ^1.0|^2.0|^3.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 adelinferaru/nestedflowtracker contains the following files

Loading the files please wait ...