This generator can be used to create PHP classes with constants for HTTP header fields, status codes and media types.
The data source is the JSON output from https://webconcepts.info which provides extensive information about the underlying concepts including links to specifications of all provided header fields, status codes and media types.
composer require crypto_scythe/http_generator --dev
./vendor/bin/http_generate.php "My\\Wanted\\Namespace" ./src/My/Wanted/Namespace
After running the command three files will be created:
HeaderFields.php
MediaTypes.php
StatusCodes.php
Every file contains constants which can be used for convenience and looking up the underlying concepts regarding them.
/**
* Authentication scheme Basic
*
* The Basic authentication scheme is based on the model that the client needs to authenticate itself with a
* user-id and a password for each protection space ("realm"). The realm value is a free-form string that can
* only be compared for equality with other realms on that server.
*
* @see https://webconcepts.info/specs/IETF/RFC/7617
* @see https://datatracker.ietf.org/doc/html/rfc7617#section-2
*/
public const BASIC = 'Basic';
/**
* Cache directive max-age
*
* The "max-age" request directive indicates that the client is unwilling to accept a response whose age is
* greater than the specified number of seconds. Unless the max-stale request directive is also present, the
* client is not willing to accept a stale response. The "max-age" response directive indicates that the
* response is to be considered stale after its age is greater than the specified number of seconds.
*
* @see https://webconcepts.info/specs/IETF/RFC/7234
* @see https://datatracker.ietf.org/doc/html/rfc7234#section-5.2.1.1
*/
public const MAX_AGE = 'max-age';
/**
* Content coding gzip
*
* The "gzip" coding is an LZ77 coding with a 32-bit Cyclic Redundancy Check (CRC) that is commonly produced by
* the gzip file compression program. A recipient SHOULD consider "x-gzip" to be equivalent to "gzip".
*
* @see https://webconcepts.info/specs/IETF/RFC/7230
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-4.2.3
*/
public const GZIP = 'gzip';
/**
* Forwarded parameter for
*
* The "for" parameter is used to disclose information about the client that initiated the request and
* subsequent proxies in a chain of proxies.
*
* @see https://webconcepts.info/specs/IETF/RFC/7239
* @see https://datatracker.ietf.org/doc/html/rfc7239#section-5.2
*/
public const FOR = 'for';
/**
* Header field Content-Type
*
* The "Content-Type" header field indicates the media type of the associated representation: either the
* representation enclosed in the message payload or the selected representation, as determined by the message
* semantics. The indicated media type defines both the data format and how that data is intended to be
* processed by a recipient, within the scope of the received message semantics, after any content codings
* indicated by Content-Encoding are decoded.
*
* @see https://webconcepts.info/specs/IETF/RFC/7231
* @see https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.5
*/
public const CONTENT_TYPE = 'Content-Type';
/**
* Link relation canonical
*
* The target (canonical) IRI MUST identify content that is either duplicative or a superset of the content at
* the context (referring) IRI.
*
* @see https://webconcepts.info/specs/IETF/RFC/6596
* @see https://datatracker.ietf.org/doc/html/rfc6596#section-3
*/
public const CANONICAL = 'canonical';
/**
* Media type application/json
*
* JavaScript Object Notation (JSON) is a text format for the serialization of structured data. It is derived
* from the object literals of JavaScript, as defined in the ECMAScript Programming Language Standard, Third
* Edition.
*
* @see https://webconcepts.info/specs/IETF/I-D/ietf-jsonbis-rfc7159bis
* @see https://datatracker.ietf.org/doc/html/draft-ietf-jsonbis-rfc7159bis#section-1
*
* JavaScript Object Notation (JSON) is a text format for the serialization of structured data. It is derived
* from the object literals of JavaScript, as defined in the ECMAScript Programming Language Standard, Third
* Edition. JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured
* types (objects and arrays).
*
* @see https://webconcepts.info/specs/IETF/RFC/8259
* @see https://datatracker.ietf.org/doc/html/rfc8259#section-1
*/
public const APPLICATION_JSON = 'application/json';
/**
* Preference wait
*
* The "wait" preference can be used to establish an upper bound on the length of time, in seconds, the client
* expects it will take the server to process the request once it has been received.
*
* @see https://webconcepts.info/specs/IETF/RFC/7240
* @see https://datatracker.ietf.org/doc/html/rfc7240#section-4.3
*/
public const WAIT = 'wait';
/**
* Range unit bytes
*
* Since representation data is transferred in payloads as a sequence of octets, a byte range is a meaningful
* substructure for any representation transferable over HTTP. The "bytes" range unit is defined for expressing
* subranges of the data's octet sequence.
*
* @see https://webconcepts.info/specs/IETF/RFC/7233
* @see https://datatracker.ietf.org/doc/html/rfc7233#section-2.1
*/
public const BYTES = 'bytes';
/**
* Request method GET
*
* The GET method requests transfer of a current selected representation for the target resource. GET is the
* primary mechanism of information retrieval and the focus of almost all performance optimizations. Hence, when
* people speak of retrieving some identifiable information via HTTP, they are generally referring to making a
* GET request.
*
* @see https://webconcepts.info/specs/IETF/RFC/7231
* @see https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.1
*/
public const GET = 'GET';
/**
* Status code 404
*
* The 404 (Not Found) status code indicates that the origin server did not find a current representation for
* the target resource or is not willing to disclose that one exists. A 404 status code does not indicate
* whether this lack of representation is temporary or permanent; the 410 (Gone) status code is preferred over
* 404 if the origin server knows, presumably through some configurable means, that the condition is likely to
* be permanent.
*
* @see https://webconcepts.info/specs/IETF/RFC/7231
* @see https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4
*/
public const STATUS_404 = 404;
public const MESSAGE_404 = 'Not Found';
public const STATUS_NOT_FOUND = self::STATUS_404;
public const MESSAGE_NOT_FOUND = self::MESSAGE_404;
/**
* Transfer coding chunked
*
* The chunked transfer coding wraps the payload body in order to transfer it as a series of chunks, each with
* its own size indicator, followed by an OPTIONAL trailer containing header fields. Chunked enables content
* streams of unknown size to be transferred as a sequence of length-delimited buffers, which enables the sender
* to retain connection persistence and the recipient to know when it has received the entire message.
*
* @see https://webconcepts.info/specs/IETF/RFC/7230
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-4.1
*/
public const CHUNKED = 'chunked';