Implement PSR-7 with Aura.Web

A while ago I was faced with the task of implementing PSR-7, the PHP recommendation for HTTP messages, within a legacy system. The main reason to want this change was because the system used a package called Aura.Web, which seemed not to be actively maintained at that time. With each new version of PHP one might wonder if at some point this package will break.

Together with my colleagues we came up with a way of using both Aura.Web and the PSR-7 implementation of GuzzleHttp. All incoming request start of as a ServerRequest, and depending on their needs, are processed as so or they are converted to an aura web request. Aura web responses are converted to a PSR-7 Response before they are presented to the end-user. All though we now can benefit from other packages that are build for PSR-7 implementations, this approach came with a downside.

Because of an earlier refactoring, all old include controller scripts are wrapped within one controller. This controller is made responsible for converting the ServerRequest into a aura web request; allowing the legacy controller scripts to function as they always did. Refactoring one of these scripts is proven to be a big task; there is more change needed than just implementing PSR-7 HTTP messages. Due to this, the system will be dependent to the Aura.Web package for a long time.

At the beginning of this project I’ve searched for a PSR-7 implementation that is build on Aura.Web. There was no such package available. Unfortunately I had not the time to build one myself, at least until now.

DMT-SOFTWARE/AURA-WEB-PSR

PSR-7 wrapper for Aura.Web implementations
source
https://github.com/dmt-software/aura-web-psr.git
license
MIT
language
PHP
downloads
8

I hope this package will help us to speed up the refactoring, because it will make it more easy to implement PSR-7 on a file base.


Posted

in

by