PHPackages                             aubes/correlation-core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. aubes/correlation-core

ActiveSymfony-bundle

aubes/correlation-core
======================

Core bundle for correlation ID management: storage, generator and shared contracts

v0.1.0(1mo ago)08↑650%MITPHPPHP ^8.2CI failing

Since Apr 6Pushed 1mo agoCompare

[ Source](https://github.com/aubes/correlation-core)[ Packagist](https://packagist.org/packages/aubes/correlation-core)[ Docs](https://github.com/aubes/correlation-core)[ RSS](/packages/aubes-correlation-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (2)Used By (0)

Correlation-core
================

[](#correlation-core)

Core bundle for correlation ID management: storage, generator, and shared interfaces.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- Symfony 6.4 / 7.4 / 8.x

Contract
--------

[](#contract)

The core of this bundle is one invariant: **`CorrelationIdProviderInterface::get()` always returns a valid, non-null string, for the entire lifetime of a request or command**.

- `CorrelationIdStorage` is `final`, self-materializes via the configured generator on first `get()`, and memoizes the result.
- `set()` validates its input and throws `InvalidCorrelationIdException` on invalid values. Last write wins.
- `reset()` clears the stored ID between contexts (`ResetInterface`).

Downstream consumers trust the value without null checks or re-validation.

Interfaces
----------

[](#interfaces)

### `CorrelationIdProviderInterface`

[](#correlationidproviderinterface)

Read-only access. Inject this in your services when you only need to read the current ID.

```
use Aubes\CorrelationCore\Storage\CorrelationIdProviderInterface;

final class MyService
{
    public function __construct(private readonly CorrelationIdProviderInterface $provider) {}

    public function doSomething(): void
    {
        $correlationId = $this->provider->get(); // guaranteed non-null, valid string
    }
}
```

> **Note**: do not implement this interface yourself. The bundle relies on `CorrelationIdStorage` being the single source of truth. If you need to seed the ID from a specific context, write a listener that calls `$storage->set(...)` (see "Extension points" below).

### `CorrelationIdStorageInterface`

[](#correlationidstorageinterface)

Full access: read, write, and reset. Extends `CorrelationIdProviderInterface` and `ResetInterface`.

```
public function get(): string;
public function set(string $id): void; // throws InvalidCorrelationIdException on invalid input
public function reset(): void;
```

### `CorrelationIdGeneratorInterface`

[](#correlationidgeneratorinterface)

```
public function generate(): string;
```

One implementation is provided:

ClassOutputUse case`UuidCorrelationIdGenerator`UUID v7 stringDefault - human-readable, time-orderedExtension points
----------------

[](#extension-points)

There are exactly two ways to customize how correlation IDs are produced:

### 1. Swap the generator

[](#1-swap-the-generator)

Replace the default UUID v7 generator with your own implementation:

```
use Aubes\CorrelationCore\Generator\CorrelationIdGeneratorInterface;

final class MyGenerator implements CorrelationIdGeneratorInterface
{
    public function generate(): string
    {
        return bin2hex(random_bytes(16));
    }
}
```

```
# config/packages/correlation_core.yaml
correlation_core:
    generator: App\MyGenerator
```

> **Note**: the service referenced by `generator` **must** implement `Aubes\CorrelationCore\Generator\CorrelationIdGeneratorInterface`.

### 2. Seed the ID from a custom context

[](#2-seed-the-id-from-a-custom-context)

Inject `CorrelationIdStorageInterface` into your own listener or middleware and call `$storage->set($id)` before the first downstream read. Any `set()` wins over the generator fallback.

```
use Aubes\CorrelationCore\Exception\InvalidCorrelationIdException;

try {
    $storage->set($idFromExternalSource);
} catch (InvalidCorrelationIdException) {
    // source untrusted: fall back to the generator by doing nothing
}
```

Console commands
----------------

[](#console-commands)

A correlation ID is generated automatically at the start of every console command and cleared when it terminates. No configuration required.

### `--correlation-id` option

[](#--correlation-id-option)

Any command can receive a specific correlation ID via the global `--correlation-id` option:

```
php bin/console app:process-orders --correlation-id=01JQWXYZ...
```

If provided, the value is validated (printable ASCII, max 255 chars) before being stored. If omitted, a UUID v7 is generated.

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance91

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

47d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea8a5dc20b3f1ea0cc24916fd22630838c9f53febedcccc107be8dfc01e095d0?d=identicon)[aubes](/maintainers/aubes)

---

Top Contributors

[![aubes](https://avatars.githubusercontent.com/u/3941035?v=4)](https://github.com/aubes "aubes (6 commits)")

---

Tags

bundlecorrelationobservabilitysymfonysymfonybundletracingcorrelation-idobservability

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aubes-correlation-core/health.svg)

```
[![Health](https://phpackages.com/badges/aubes-correlation-core/health.svg)](https://phpackages.com/packages/aubes-correlation-core)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M685](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M171](/packages/sulu-sulu)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

84434.9k](/packages/flow-php-flow)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[contao/core-bundle

Contao Open Source CMS

1301.6M2.5k](/packages/contao-core-bundle)[sensiolabs/gotenberg-bundle

A Symfony bundle that provides seamless integration with Gotenberg for generating PDFs and screenshots from various sources (HTML, Markdown, Office documents, URLs) with a clean, builder-based API.

225296.3k2](/packages/sensiolabs-gotenberg-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
