PSR-15 compatibility (request handlers / middleware) #185
Replies: 5 comments 5 replies
-
I'm all for it. |
Beta Was this translation helpful? Give feedback.
-
Is there a downside? Just asking because I suppose there was a reason why it wasn't done in the first place and the current implementation looks very similar. |
Beta Was this translation helpful? Give feedback.
-
Agree that PSR-15 compatibility would be a fantastic addition for Framework X! 💯 It's a perfect fit for its design and I'm especially looking forward to being able to reuse all the existing middleware implementations from the entire PHP ecosystem! Semantically, PSR-15 defines the exact same interfaces defined by Framework X, except that Framework X also support async responses using promises and coroutines. Now that full fiber support has been merged via #168 and #128, full PSR-15 compatibility is finally feasible. Support for final request handlers (controllers) should be pretty straight forward, as it's only really a matter of calling its Support for middleware request handlers is going to require a bit of work as the TLDR: Definitely enjoys priority and would love to have this! There's hope this discussion can help us prioritize outstanding feature requests and steer project development. |
Beta Was this translation helpful? Give feedback.
-
I haven't actually tested this yet, but for/http-middleware-psr15-adapter should work fine with Framework X. Annoying to wrap each Middleware, but a first party solution using the same techniques should make a simple solution. |
Beta Was this translation helpful? Give feedback.
-
I would like to promote framework-x with a open API library of mine, but my integration is a PSR-15 middleware. My (maybe naive) approach would be to simply tweak the class MiddlewareHandler
{
/** @var list<callable> $handlers */
private $handlers;
/** @param list<callable|MiddlewareInterface> $handlers */
public function __construct(array $handlers)
{
assert(count($handlers) >= 2);
$this->handlers = array_map(function ($handler) {
return $handler instanceof MiddlewareInterface ? new PsrMiddlewareAdapter($handler) : $handler;
}, $handlers);
} But I was wondering whether that adapter needs the |
Beta Was this translation helpful? Give feedback.
-
PSR-15 compatibility would be a useful addition to Framework X. Not only will this introduce lots of interoperability with most middleware (or other projects) out there, it will also help us in our doing when it comes to new features for Framework X. Not every addition to the project needs to be integrated in X, in some cases it makes more sense to offer separate solutions. This way we don't overload the project itself.
Curious what you think about this addition!
Beta Was this translation helpful? Give feedback.
All reactions