relayphp / Relay.Relay

A PSR-15 server request handler.
http://relayphp.com
MIT License
320 stars 17 forks source link

Help: migrate from Relay 1 to Relay 2? #50

Closed cj-clx closed 4 years ago

cj-clx commented 4 years ago

I've got an application which is currently using Relay 1.x. I'd like to migrate it to Relay 2.x as part of wider modernization of that app.

Any chance someone could briefly outline the changes needed, or point me at resources that would help?

kevinsmith commented 4 years ago

Unfortunately the method signatures for double-pass (Relay v1) and single-pass (Relay v2) middleware are incompatible, so there's no easy way to use a converter or automate the change. (Without losing the response anyway.)

For any third-party middleware, you'll just need to look for PSR-15 compatible alternatives. Here's a couple great resources:

For custom middleware, you'll need to refactor to use the new single-pass method signature instead. To give you a better idea of what that might look like, here's a good example of both methods of middleware for the same underlying package:

Hope this helps!