Class constants for HTTP statuses.
Add it to your composer.json:
"mckay/httpstatus": "^1.0.4",then run $ composer update.
use \McKay\HttpStatus;
if (!$user->isRoot()) {
renderView(...);
HttpStatus::set(HttpStatus::UNAUTHORIZED);
return;
}
if (empty($resource)) {
renderError(...);
HttpStatus::set(HttpStatus::NOT_FOUND);
return;
}
function renderError(...) {
$code = HttpStatus::get();
$description = HttpStatus::text();
...
}See the source for the complete list of available HTTP status constants.
Copyright © McKay Software
MIT License
http://mckay.mit-license.org