2026-01-31 21:23 UTC
What if we could run a list of middlewares without the stack trace becoming deeper than 1?
After talking about crazy PHP things with @sebastian @nielsdos and @Girgias this mad idea came to me on the train back from #fosdem
Took 3 attempts to make it work, and its clumsy becuse you need to call yield and then $response = yield;
Or is there a better way?
Anyways, stacktrace only has depth 1 here for each Middleware::process call.
Wdyt?
https://gist.github.com/beberlei/c958c24bcea4b08013eb1126e65fefce
Replies (2)
-
@beberlei@phpc.social 2026-01-31 21:40
Ok, writing about stuff and putting them out there helps with ideas, if I introduce a context that references the response, then i can get rid of the double yield, for more clarity. https://gist.github.com/beberlei/5f36deb1303b7080eff8e2b9765187cc
-
@tobyS@ruhr.social 2026-02-01 06:59
@beberlei@phpc.social: Using `yield` in such a way still makes 🤯. But that's probably because I'm old. 😅 /cc @sebastian@phpc.social @nielsdos@phpc.social @Girgias@phpc.social