mckay/httpstatus

Easy HTTP statuses.

v1.0.6 2015-05-07 23:28 UTC

This package is not auto-updated.

Last update: 2024-04-27 15:09:55 UTC


README

Class constants for HTTP statuses.

Install

Add it to your composer.json:

"mckay/httpstatus": "^1.0.4",

then run $ composer update.

Usage

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.

License

Copyright © McKay Software
MIT License
http://mckay.mit-license.org