-
Http package now expose all status code constants via Response class. So we can remove all the hard coded status. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@shuvroroy Thanks for bringing this up! It's correct that the upcoming version of ReactPHP's HTTP package will finally expose HTTP status code constants next to using their numeric values: reactphp/http#432 🎉 $app->get('/old', function () {
return new React\Http\Message\Response(
200,
[],
"Hello wörld!\n"
);
});
$app->get('/new', function () {
return new React\Http\Message\Response(
React\Http\Message\Response::STATUS_OK,
[],
"Hello wörld!\n"
);
}); The PR has already been merged, but a release is still outstanding at the moment. I'll look into making sure this can be released asap. Once this is released, we can immediately take advantage of this in X, so there are no changes required (except perhaps raising the minimum requirement and adjusting the documentation). Expect this to be available some time in the next couple of weeks! |
Beta Was this translation helpful? Give feedback.
-
#114 has just been merged, so the following examples are now supported out of the box! 🎉 $app->get('/user', function () {
return React\Http\Message\Response::plaintext(
"Hello wörld!\n"
);
});
$app->get('/users', function () {
return React\Http\Message\Response::plaintext(
"Not found.\n"
)->withStatus(React\Http\Message\Response::STATUS_NOT_FOUND);
}); All status codes are now available as status constants like See also updated docs: https://framework-x.org/docs/api/response/#status-codes |
Beta Was this translation helpful? Give feedback.
#114 has just been merged, so the following examples are now supported out of the box! 🎉
All status codes are now available as status constants like
React\Http\Message\Response::STATUS_OK
orReact\Http\Message\Response::STATUS_NOT_FOUND
etc.See also updated docs: https://framework-x.org/docs/api/response/#status-codes