Kevin Eaton

Keeping the log

Publish and run the migration:

php artisan vendor:publish --tag=pipe-dream-migrations
php artisan migrate

Then give the envelope a DatabasePersistStrategy. Wrap the subject yourself with PipeEnvelope::wrap() to set things like this before the run:

<?php

use Keaton\PipeDream\Models\PipeDreamLog;
use Keaton\PipeDream\PipeEnvelope;
use Keaton\PipeDream\PipeHub;
use Keaton\PipeDream\PipeManager;
use Keaton\PipeDream\Strategies\DatabasePersistStrategy;

$post = (object) ['title' => '  hello,   PIPE dream  '];

$envelope = PipeEnvelope::wrap($post)->persistWith(new DatabasePersistStrategy());

PipeManager::create([
    PipeHub::create()->name('Tidy')->addPipes([TidyTitle::class]),
    PipeHub::create()->name('Slug')->addPipes([SlugifyTitle::class]),
])->name('Publish a post')->subject($envelope)->sendIt();

PipeDreamLog::where('run_id', $envelope->runId())->count();   // 1

A manager saves once, when the flow ends, however it ended: one row per run, in pipe_dream_logs. Saving the same run again updates its row. Read a run back later, with every record intact:

<?php

use Keaton\PipeDream\Models\PipeDreamLog;

$run = PipeDreamLog::where('flow', 'Publish a post')->latest()->firstOrFail();

$run->has_fatals;                                                       // false
$run->logger()->infos()->firstWhere('key', TidyTitle::class)['data'];    // 'Title is now "Hello, Pipe Dream"'

Here's what all that saved information lets you do — pull any single click back whole and see its entire path through the pipeline, stage by stage:

One click's full story

One real click, replayed from the log: every stage, every pass, skip and flag — long after it happened.