Download the PHP package rigsto/api-http-status without Composer
On this page you can find all versions of the php package rigsto/api-http-status. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rigsto/api-http-status
More information about rigsto/api-http-status
Files in rigsto/api-http-status
Package api-http-status
Short Description HTTP status codes and resources for API usages
License MIT
Informations about the package api-http-status
Http Status Codes and API Response
A simple enum class for HTTP status codes and their associated API response.
All codes are taken from Wikipedia.
Installation
Using composer:
Usage
Http Status Code
Enum
Functions
getStatusCode()
will return the status code.
getName()
will return the http name.
getCategory()
will return the http category.
isSuccess()
will return true if the status code is a success code.
Generate Http Status From Code
isValidCode()
will return true
if the code is valid and false
if it is not.
fromCode()
will return an HttpStatus
object if the code is valid and null
if it is not.
Api Response
generateResponse(HttpStatus, ?message, ?data)
will return json string of the http status, message, and data.
HttpStatus
is required, but message
and data
are optional. If message
is null, then message will be generated from http status name.
generateSuccessResponse(?message, ?data)
will return json string of the http status, message, and data. This method is same with function above, but it generates response with HttpStatus::OK
as http status.
generateUnauthorizedResponse()
will return json string with unauthorized http status and message.
generatePaginationResponse(HttpStatus, ?message, ?data
will return json string of http status, message, and paginate data.
Function concept same as generateResponse()
but with pagination data.
All versions of api-http-status with dependencies
illuminate/support Version ^9.0.0|^10.0.0
illuminate/http Version ^9.0.0|^10.0.0
symfony/process Version ^v6.4.0