Orpheus

FileHttpResponse extends HttpResponse
in package

Table of Contents

Constants

DEFAULT_MIMETYPE  = 'text/plain'
Default mimetype

Properties

$body  : string|null
The HTML body of the response
$cacheMaxAge  : int|null
Client cache max age in seconds
$code  : int|null
The HTTP response code
$contentLength  : int|null
$contentType  : string|null
$controllerOutput  : string|null
The output of the controller when running it
$download  : bool
Is the file downloaded ? Or displayed ?
$extensionMimeTypes  : array<string|int, mixed>
Registered mimetype for extension
$fileName  : string|null
The file name shared to the client
$lastModifiedDate  : DateTime|null
Client cache max age in seconds
$resource  : resource|null
The resource of file

Methods

__construct()  : mixed
Constructor
__toString()  : string
Get this response as string
collectFrom()  : void
generateFromException()  : static
Generate OutputResponse from Exception
generateFromUserException()  : static
Generate OutputResponse from UserException
getBody()  : string
Get the body
getCacheMaxAge()  : int
getCode()  : int|null
Get the code
getContentLength()  : int
getContentType()  : string|null
getControllerOutput()  : string|null
Get the controller output
getFileName()  : string
getHttpDateFormat()  : string
getLastModifiedDate()  : DateTime
getMimeType()  : string
Get mimetype
getSize()  : int
isDownload()  : bool
process()  : void
Process the response
run()  : bool
Process response to client
setBody()  : HttpResponse
Set the body
setCacheMaxAge()  : void
setCode()  : HttpResponse
Set the code
setContentLength()  : void
setContentType()  : void
setControllerOutput()  : void
Set the controller output
setDownload()  : void
setFileName()  : void
setLastModifiedDate()  : $this
getContentDisposition()  : string
Get content disposition header value
getMimetypeFromExtension()  : string
Get mimetype from extension
sendHeaders()  : void
setExtensionMimetype()  : void
Set extension's mimetype

Constants

DEFAULT_MIMETYPE

Default mimetype

public string DEFAULT_MIMETYPE = 'text/plain'

Properties

$body

The HTML body of the response

protected string|null $body = null

$cacheMaxAge

Client cache max age in seconds

protected int|null $cacheMaxAge = null

$code

The HTTP response code

protected int|null $code = null

$contentLength

protected int|null $contentLength = null

The content length to send to client

$contentType

protected string|null $contentType = null

The content type to send to client

$controllerOutput

The output of the controller when running it

protected string|null $controllerOutput = null

$download

Is the file downloaded ? Or displayed ?

protected bool $download = false

$extensionMimeTypes

Registered mimetype for extension

protected static array<string|int, mixed> $extensionMimeTypes = ['css' => 'text/css', 'js' => 'application/javascript', 'pdf' => 'application/pdf']

$fileName

The file name shared to the client

protected string|null $fileName = null

$lastModifiedDate

Client cache max age in seconds

protected DateTime|null $lastModifiedDate = null

Methods

__construct()

Constructor

public __construct(resource|null $resource, string $fileName[, bool $download = true ][, int $cacheMaxAge = 0 ]) : mixed
Parameters
$resource : resource|null

resource to get read while rendering, pass null and override run() to get it by your own way

$fileName : string
$download : bool = true
$cacheMaxAge : int = 0

__toString()

Get this response as string

public __toString() : string
Return values
string

collectFrom()

public collectFrom(string $layout[, array<string|int, mixed> $values = [] ]) : void
Parameters
$layout : string
$values : array<string|int, mixed> = []

generateFromException()

Generate OutputResponse from Exception

public static generateFromException(Throwable $exception[, array<string|int, mixed> $values = [] ]) : static
Parameters
$exception : Throwable
$values : array<string|int, mixed> = []
Return values
static

generateFromUserException()

Generate OutputResponse from UserException

public static generateFromUserException(UserException $exception[, array<string|int, mixed> $values = [] ]) : static
Parameters
$exception : UserException
$values : array<string|int, mixed> = []
Return values
static

getBody()

Get the body

public getBody() : string
Return values
string

getCacheMaxAge()

public getCacheMaxAge() : int
Return values
int

getCode()

Get the code

public getCode() : int|null
Return values
int|null

getContentLength()

public getContentLength() : int
Return values
int

getContentType()

public getContentType() : string|null
Return values
string|null

getControllerOutput()

Get the controller output

public getControllerOutput() : string|null
Return values
string|null

getFileName()

public getFileName() : string
Return values
string

getHttpDateFormat()

public getHttpDateFormat() : string
Return values
string

getLastModifiedDate()

public getLastModifiedDate() : DateTime
Return values
DateTime

getMimeType()

Get mimetype

public getMimeType() : string
Return values
string

isDownload()

public isDownload() : bool
Return values
bool

setCacheMaxAge()

public setCacheMaxAge(int $cacheMaxAge) : void
Parameters
$cacheMaxAge : int

setContentLength()

public setContentLength(int $contentLength) : void
Parameters
$contentLength : int

setContentType()

public setContentType(string $contentType) : void
Parameters
$contentType : string

setControllerOutput()

Set the controller output

public setControllerOutput(string $controllerOutput) : void
Parameters
$controllerOutput : string

setDownload()

public setDownload(bool $download) : void
Parameters
$download : bool

setFileName()

public setFileName(string $fileName) : void
Parameters
$fileName : string

setLastModifiedDate()

public setLastModifiedDate(DateTime|int $lastModifiedDate) : $this
Parameters
$lastModifiedDate : DateTime|int

DateTime or timestamp

Return values
$this

getContentDisposition()

Get content disposition header value

protected getContentDisposition() : string
Return values
string

getMimetypeFromExtension()

Get mimetype from extension

protected static getMimetypeFromExtension(string $extension) : string
Parameters
$extension : string
Return values
string

setExtensionMimetype()

Set extension's mimetype

protected static setExtensionMimetype(string $extension, string $mimetype) : void
Parameters
$extension : string
$mimetype : string

							
On this page

Search results