Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins vs PSR-15 middleware #168

Open
dbu opened this issue Jan 28, 2019 · 2 comments
Open

Plugins vs PSR-15 middleware #168

dbu opened this issue Jan 28, 2019 · 2 comments

Comments

@dbu
Copy link
Contributor

dbu commented Jan 28, 2019

reading https://medium.com/@timoschinkel/implementing-psr-18-and-extending-it-with-middleware-b33eeceb2753 it occured to me that our PluginClient essentially mimiks PSR-15. should we migrate our plugins to middleware, or is there value in having them as they are?

@joelwurtz
Copy link
Member

We cannot use PSR15 as it only accept a ServerRequestInterface (and it's way better, as client middleware does not have the same purpose as server middleware)

Also actually our plugin system rely on Promise as it's easy to switch from async to sync, but impossible to do otherwise (at least for php < 7.3)

However, i really believe in https://github.com/concurrent-php/ext-async which will allow us to use a PSR15 like interface for our plugin system (sync version) but still allow for async operation.

Also the $first variable in our plugin can be dropped (we just need to inject an http client into plugin using this variable)

So our interface can become something like :

use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

interface Plugin {
    handleRequest(RequestInterface $request, ClientInterface $next): ResponseInterface;
}

@johnss
Copy link

johnss commented Nov 16, 2019

is there exist proposal for creating http client middleware for future PSR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants