Orpheus

loader.php

Tags
author

Florent HAZARD f.hazard@sowapps.com

Table of Contents

Constants

DEFAULT_PACKAGES  = ['@application']
ERROR_DEBUG_LEVEL  = \E_ALL
ERROR_PROD_LEVEL  = \E_CORE_ERROR
HTTP_BAD_REQUEST  = 400
HTTP_FORBIDDEN  = 403
HTTP_FOUND  = 302
HTTP_INTERNAL_SERVER_ERROR  = 500
HTTP_MOVED_PERMANENTLY  = 301
HTTP_MOVED_TEMPORARILY  = \HTTP_FOUND
HTTP_NOT_FOUND  = 404
HTTP_OK  = 200
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
HTTP_UNAUTHORIZED  = 401

Functions

defifn()  : true
Define an undefined constant.
safeConstant()  : mixed|null
Get the nullable value of the constant
getParentPath()  : string
Gets the directory path
pathOf()  : string|null
Gets the path of a file/directory.
existsPathOf()  : bool
Checks if the path exists.
addSrcPath()  : bool
Add the path to the known paths
listSrcPath()  : array<string|int, string>
List all source paths
includeFolder()  : int
Include a directory
escapeText()  : string
Escape the text $str from special characters
http_response_code_text()  : mixed
displayException()  : never
displayExceptionAsHTML()  : never
displayExceptionAsText()  : never
typeOf()  : string
displayRawException()  : void
displayStackTraceAsHtml()  : void
displayExceptionStackTrace()  : void
getClassName()  : string
processException()  : void
getErrorException()  : ErrorException
convertExceptionAsHTMLPage()  : string
convertExceptionAsText()  : string
formatSourceAsText()  : string
getFileLines()  : array<string|int, mixed>|string
str_limit()  : string
Limits the length of a string and append $end.

Constants

DEFAULT_PACKAGES

public mixed DEFAULT_PACKAGES = ['@application']

ERROR_DEBUG_LEVEL

public mixed ERROR_DEBUG_LEVEL = \E_ALL

ERROR_PROD_LEVEL

public mixed ERROR_PROD_LEVEL = \E_CORE_ERROR

HTTP_BAD_REQUEST

public mixed HTTP_BAD_REQUEST = 400

HTTP_FORBIDDEN

public mixed HTTP_FORBIDDEN = 403

HTTP_FOUND

public mixed HTTP_FOUND = 302

HTTP_INTERNAL_SERVER_ERROR

public mixed HTTP_INTERNAL_SERVER_ERROR = 500

HTTP_MOVED_PERMANENTLY

public mixed HTTP_MOVED_PERMANENTLY = 301

HTTP_MOVED_TEMPORARILY

public mixed HTTP_MOVED_TEMPORARILY = \HTTP_FOUND

HTTP_NOT_FOUND

public mixed HTTP_NOT_FOUND = 404

HTTP_OK

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

public mixed HTTP_OK = 200

HTTP_UNAUTHORIZED

public mixed HTTP_UNAUTHORIZED = 401

Functions

defifn()

Define an undefined constant.

defifn(string $name, string|int|bool $value) : true
Parameters
$name : string

The name of the constant.

$value : string|int|bool

The value of the constant.

Return values
true

if the constant was defined successfully, else False.

safeConstant()

Get the nullable value of the constant

safeConstant(string $name) : mixed|null
Parameters
$name : string
Return values
mixed|null

The value of constant or null if undefined

getParentPath()

Gets the directory path

getParentPath(string $path) : string
Parameters
$path : string

The path get parent directory

Tags
see
dirname()
Return values
string

The secured path

pathOf()

Gets the path of a file/directory.

pathOf(string $relativePath[, bool $silent = false ]) : string|null

This function uses global variable $APP_SOURCE_PATHS to get the known paths. It allows developers to get a dynamic path to a file.

Parameters
$relativePath : string

The common path

$silent : bool = false

Do not throw exception if path does not exist

Tags
see
addSrcPath()
Return values
string|null

The first valid path or null if there is no valid one.

existsPathOf()

Checks if the path exists.

existsPathOf(string $commonPath[, string|null &$path = null ]) : bool

This function uses pathOf() to determine possible path of $commonPath and checks if there is any file with this path in file system.

Parameters
$commonPath : string

The common path

$path : string|null = null

The output parameter to get the first valid path

Tags
throws
Exception
see
pathOf()
Return values
bool

addSrcPath()

Add the path to the known paths

addSrcPath(string $path) : bool
Parameters
$path : string

The source path to add.

Tags
see
pathOf()
Return values
bool

True if the path was added.

listSrcPath()

List all source paths

listSrcPath() : array<string|int, string>
Return values
array<string|int, string>

includeFolder()

Include a directory

includeFolder(string $folder[, array<string|int, mixed> $importants = [] ]) : int
Parameters
$folder : string

The directory to include.

$importants : array<string|int, mixed> = []

The files in that are importants to load first.

Return values
int

The number of files included.

Include all files with a name beginning by '_' in the directory $dir. It browses recursively through sub folders.

escapeText()

Escape the text $str from special characters

escapeText(string $str[, int $flags = ENT_NOQUOTES ]) : string
Parameters
$str : string

The string to escape

$flags : int = ENT_NOQUOTES

The flags of htmlentities()

Return values
string

The escaped string

http_response_code_text()

http_response_code_text([int|null $code = null ]) : mixed
Parameters
$code : int|null = null

displayException()

displayException(Throwable $Exception) : never
Parameters
$Exception : Throwable
Return values
never

displayExceptionAsHTML()

displayExceptionAsHTML(Throwable $Exception) : never
Parameters
$Exception : Throwable
Return values
never

displayExceptionAsText()

displayExceptionAsText(Throwable $Exception) : never
Parameters
$Exception : Throwable
Return values
never

typeOf()

typeOf(mixed $var) : string
Parameters
$var : mixed
Return values
string

displayRawException()

displayRawException(Throwable $Exception) : void
Parameters
$Exception : Throwable

displayStackTraceAsHtml()

displayStackTraceAsHtml(array<string|int, mixed> $backtrace) : void
Parameters
$backtrace : array<string|int, mixed>

displayExceptionStackTrace()

displayExceptionStackTrace(Throwable $Exception) : void
Parameters
$Exception : Throwable

getClassName()

getClassName(object|string $var) : string
Parameters
$var : object|string
Return values
string

processException()

processException(Throwable $exception[, mixed $log = null ]) : void
Parameters
$exception : Throwable
$log : mixed = null

getErrorException()

getErrorException(array<string|int, mixed> $error) : ErrorException
Parameters
$error : array<string|int, mixed>
Return values
ErrorException

convertExceptionAsHTMLPage()

convertExceptionAsHTMLPage(Throwable $exception, int $code) : string
Parameters
$exception : Throwable
$code : int
Return values
string

convertExceptionAsText()

convertExceptionAsText(Throwable $Exception, int $code) : string
Parameters
$Exception : Throwable
$code : int
Return values
string

formatSourceAsText()

formatSourceAsText(mixed $file, int $activeLineNumber, int $linesBefore, int $linesAfter) : string
Parameters
$file : mixed
$activeLineNumber : int
$linesBefore : int
$linesAfter : int
Return values
string

getFileLines()

getFileLines(mixed $file, int $from, int $to[, int &$count = 0 ][, bool $asArray = false ]) : array<string|int, mixed>|string
Parameters
$file : mixed
$from : int
$to : int
$count : int = 0
$asArray : bool = false
Return values
array<string|int, mixed>|string

str_limit()

Limits the length of a string and append $end.

str_limit(string $string, int $max[, string $end = '...' ]) : string

This function do it cleanly, it tries to cut before a word.

Parameters
$string : string

The string to limit length.

$max : int

The maximum length of the string.

$end : string = '...'

A string to append to the shortened string.

Return values
string

The shortened string.


							
On this page

Search results