Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Matthew Weier O’Phinney: PSR-7 Request and Method Utilities

Matthew Weier O’Phinney: PSR-7 Request and Method Utilities

Matthew Weier O’Phinney has written up a new post for his site covering PSR-7 request and method utilities and a package that contains some handy tools to help with just that.

Some time ago, a few folks floated the idea of creating a utility repository related to the PSR-7 psr/http-message package, but containing some useful bits such as constants for HTTP request methods and status codes.

Six months ago, we released it… but didn’t publicize it. I remembered that fact today while writing some unit tests that were utilizing the package, and thought I’d finally write it up.

The package is fig/http-message-util, and is available via Composer and Packagist.

He goes on to describe the two interfaces it provides (RequestMethod and StatusCode) and what they’re designed to help with. He includes an example of middleware written using these interfaces, defining allowed methods and returning a "method not allowed" status code – based on a constant – in the response message object. He ends the post with two quick points to note in this example: how the interfaces are used and his use of aliases to make using the interfaces just a bit shorter.

Source: http://www.phpdeveloper.org/news/24851

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Posted Styczeń 28th, 2017 in WEB and PHP Development.

Leave a response: