What a pipeline is
A pipeline sends one value (the subject) through a list of steps (the pipes), in order. Each pipe gets the subject, does its bit, and passes it on. Laravel ships one, Illuminate\Pipeline\Pipeline, and the pipes can be plain closures:
<?php
use Illuminate\Pipeline\Pipeline;
$post = (object) ['title' => ' hello, PIPE dream '];
app(Pipeline::class)
->send($post)
->through([
function ($post, $next) {
$post->title = trim($post->title);
return $next($post);
},
function ($post, $next) {
$post->title = preg_replace('/\s+/', ' ', $post->title);
return $next($post);
},
function ($post, $next) {
$post->title = ucwords(strtolower($post->title));
return $next($post);
},
])
->thenReturn();
echo $post->title;
Hello, Pipe Dream