VELOX API Docs

App extends App
in package

Alias

Table of Contents

ON_SHUTDOWN  = 'app.on.shutdown'
This event will be dispatched on app shutdown. Note that this event is dispatched only once in app life-cycle.
ON_TERMINATE  = 'app.on.terminate'
This event will be dispatched on app termination. Note that this event can be dispatched multiple times in app life-cycle.
$auth  : Auth
$config  : Config
$data  : Data
$database  : Database
$dumper  : Dumper
$event  : Event
$globals  : Globals
$html  : HTML
$misc  : Misc
$path  : Path
$router  : Router
$session  : Session
$view  : View
$instance  : self
The class singleton instance.
$methods  : array<string|int, mixed>
$staticMethods  : array<string|int, mixed>
__call()  : mixed
__callStatic()  : mixed
__construct()  : mixed
Class constructor.
abort()  : void
Aborts the current request and sends a response with the specified HTTP status code, title, and message.
extend()  : callable
Extends the class using the passed callback.
extendStatic()  : callable
Extends the class using the passed callback.
handleError()  :
handleException()  :
instance()  : static
Returns the singleton instance of the `App` class.
log()  : bool
Logs a message to a file and generates it if it does not exist.
terminate()  : void
Terminates (exits) the PHP script.

Constants

ON_SHUTDOWN

This event will be dispatched on app shutdown. Note that this event is dispatched only once in app life-cycle.

public string ON_SHUTDOWN = 'app.on.shutdown'

This event will not be passed any arguments.

ON_TERMINATE

This event will be dispatched on app termination. Note that this event can be dispatched multiple times in app life-cycle.

public string ON_TERMINATE = 'app.on.terminate'

This event will not be passed any arguments.

Properties

$instance

The class singleton instance.

protected static self $instance

$methods

protected array<string|int, mixed> $methods

$staticMethods

protected static array<string|int, mixed> $staticMethods

Methods

__call()

public __call(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
$method : string
$arguments : array<string|int, mixed>
Return values
mixed

__callStatic()

public static __callStatic(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
$method : string
$arguments : array<string|int, mixed>
Return values
mixed

__construct()

Class constructor.

public __construct() : mixed
Return values
mixed

abort()

Aborts the current request and sends a response with the specified HTTP status code, title, and message.

public static abort(int $code[, string|null $title = null ][, string|null $message = null ]) : void

An HTML page will be rendered with the specified title and message. If a view file for the error page is set using {global.errorPages.CODE}, it will be rendered instead of the normal page and passed the $code, $title, and $message variables. The title for the most common HTTP status codes (200, 401, 403, 404, 405, 500, 503) is already configured.

Parameters
$code : int

The HTTP status code.

$title : string|null = null

[optional] The title of the HTML page.

$message : string|null = null

[optional] The message of the HTML page.

Tags
since
1.2.5
Return values
void

extend()

Extends the class using the passed callback.

public extend(string $name, callable $callback) : callable
Parameters
$name : string

Method name.

$callback : callable

The callback to use as method body.

Return values
callable

The created bound closure.

extendStatic()

Extends the class using the passed callback.

public static extendStatic(string $name, callable $callback) : callable
Parameters
$name : string

Method name.

$callback : callable

The callback to use as method body.

Return values
callable

The created closure.

handleError()

public static handleError(int $code, string $message, string $file, int $line) :

This method is available only at shutdown.

Parameters
$code : int
$message : string
$file : string
$line : int
Return values

handleException()

public static handleException(Throwable $expression) :

This method is available only at shutdown.

Parameters
$expression : Throwable
Return values

instance()

Returns the singleton instance of the `App` class.

public final static instance() : static

NOTE: This method returns only the first instance of the class which is normally the one that was created during application bootstrap.

Tags
since
1.4.0
Return values
static

log()

Logs a message to a file and generates it if it does not exist.

public static log(string $message[, array<string|int, mixed>|null $context = [] ][, string|null $filename = null ][, string|null $directory = null ]) : bool
Parameters
$message : string

The message wished to be logged.

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

An associative array of values where array key = {key} in the message (context).

$filename : string|null = null

[optional] The name wished to be given to the file. If not provided {global.logging.defaultFilename} will be used instead.

$directory : string|null = null

[optional] The directory where the log file should be written. If not provided {global.logging.defaultDirectory} will be used instead.

Return values
bool

True on success (if the message was written).

terminate()

Terminates (exits) the PHP script.

public static terminate([int|string|null $status = null ][, bool $noShutdown = true ]) : void

This function is used instead of PHP exit to allow for testing exit without breaking the unit tests.

Parameters
$status : int|string|null = null

The exit status code/message.

$noShutdown : bool = true

Whether to not execute the shutdown function or not.

Tags
throws
Exception

If EXIT_EXCEPTION is defined and truthy.

since
1.2.5
Return values
void

This function never returns. It will terminate the script.

Search results