This changeset adds factory methods for common HTML/JSON/plaintext/XML response types:
$response = React\Http\Response\html("<h1>Hello wörld!</h1>\n"); $response = React\Http\Response\json(['message' => 'Hello wörld!']); $response = React\Http\Response\plaintext("Hello wörld!\n"); $response = React\Http\Response\xml("<message>Hello wörld!</message>\n");
Using the new factory methods is entirely optional and directly using the Response constructor remains supported of course, but we now use these factory methods throughout our documentation and examples to make them more readable. Accordingly, this does not affect backwards compatibility.
This builds on top of #403 (thank you @WyriHaximus!), but instead of exposing a new class, this changeset simply adds a number of static methods to the existing Response class. This makes it easier to use these methods in application code because no separate import is required, in particular when using the HTTP status code constants implemented in #432.