Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Paul Jones:
The PHP 7 “Request” Extension
Nov 23, 2016 @ 20:37:09

Paul Jones has a new post to his site introducing the "Request" extension he and John Boehr have worked up to make working with HTTP requests in PHP simpler.

You’re tired of dealing with the $_GET, $_POST, etc. superglobals in your PHP 7 application. You wish $_FILES was easer to deal with. You’d prefer to wrap them all in an object to pass around to your class methods, so they’d be easier to test. [...] You could maybe adopt a framework, but why do that for your custom project? Just a pair of server-side request and response objects would make your life so much easer. Why can’t there be set of internal PHP classes for that?

Well, now there is. You can install the request extension from John Boehr and myself to get ServerRequest and ServerReponse objects as if PHP itself provided them.

He gives an example of using the extension to work with both the request and response (ServerRequest and ServerResponse). This includes cookie values, files handling, content length and much more. There's code examples showing it in use and a link to the repository for the extension where you can find out more.

tagged: request extension language serverrequest serverresponse

Link: http://paul-m-jones.com/archives/6416


Trending Topics: