VELOX API Docs

helpers.php

Table of Contents

app()  : App
Returns an instance of the `App` class.
abort()  : void
Aborts the current request and sends a response with the specified HTTP status code, title, and message.
terminate()  : void
Terminates (exits) the PHP script.
config()  : mixed|Config
Gets or sets a value of a key from the configuration via dot-notation (0 param -> the `Config` class instance, 1 param -> get by key, 2 params -> set by key).
event()  : Event
Returns an instance of the `Event` class.
router()  : Router
Returns an instance of the `Router` class.
handle()  : static
Registers a handler for a route.
redirect()  : void
Redirects the request to another route.
forward()  : void
Forwards the request to another route.
globals()  : Globals
Returns an instance of the `Globals` class.
session()  : Session
Returns an instance of the `Session` class.
flash()  : object
Returns an instance of the `Flash` class.
csrf()  : object
Returns an instance of the `CSRF` class.
database()  : Database
Returns an instance of the `Database` class.
auth()  : Auth
Returns an instance of the `Auth` class.
view()  : View
Returns an instance of the `View` class.
render()  : string
Renders a view (a Page wrapped in a Layout) with the passed variables, the Page content will be sent to `{view.defaultSectionName}` section.
render_layout()  : string
Renders a theme layout with the passed variables.
render_page()  : string
Renders a theme page with the passed variables.
render_partial()  : string
Renders a theme partial with the passed variables.
section_push()  : void
Pushes content to the buffer of the section with the given name.
section_reset()  : void
Resets (empties) the buffer of the section with the given name.
section_start()  : void
Ends capturing buffer of the section with the given name. Works in conjunction with `self::sectionStart()`.
section_end()  : void
Ends capturing buffer of the section with the given name. Works in conjunction with `self::sectionStart()`.
section_yield()  : string
Returns content of the section with the given name.
include_file()  : void
Includes a file from the active theme directory.
data()  : Data
Returns an instance of the `Data` class.
data_has()  : bool
Checks whether a value of a key exists in `self::$bag` via dot-notation.
data_get()  : mixed
Gets a value of a key from `self::$bag` via dot-notation.
data_set()  : void
Sets a value of a key in `self::$bag` via dot-notation.
html()  : HTML
Returns an instance of the `HTML` class.
path()  : Path
Returns an instance of the `Path` class.
app_path_current()  : string|bool
Returns the current path, or compares it with the passed parameter. Note that the path does not contain the query string.
app_url_current()  : string|bool
Returns the current URL, or compares it with the passed parameter.
app_path()  : string
Resolves the passed path to the app root path and returns it.
app_url()  : string
Resolves the passed path to the base URL (starting from app root) and returns it.
theme_path()  : string
Resolves the passed path to the theme root path and returns it.
theme_url()  : string
Resolves the passed path to the base URL (starting from active theme root) and returns it.
assets_path()  : string
Resolves the passed path to the assets directory and returns it.
assets_url()  : string
Resolves the passed path to the base URL (starting from active theme assets root) and returns it.
dd()  : void
Dumps a variable and dies.
dump()  : void
Dumps a variable in a nice HTML block with syntax highlighting.
dump_exception()  : void
Dumps an exception in a nice HTML page or as string and exits the script.

Functions

app()

Returns an instance of the `App` class.

app() : App
Return values
App —

abort()

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

abort() : 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.

Tags
since
1.2.5
Return values
void —

terminate()

Terminates (exits) the PHP script.

terminate() : void

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

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.

config()

Gets or sets a value of a key from the configuration via dot-notation (0 param -> the `Config` class instance, 1 param -> get by key, 2 params -> set by key).

config() : mixed|Config
Tags
since
1.0.0
Return values
mixed|Config —

The requested value or null or the Config object if no parameters are given.

event()

Returns an instance of the `Event` class.

event() : Event
Tags
since
1.2.0
Return values
Event —

router()

Returns an instance of the `Router` class.

router() : Router
Tags
since
1.0.0
Return values
Router —

handle()

Registers a handler for a route.

handle() : static
Tags
since
1.0.0
Return values
static —

redirect()

Redirects the request to another route.

redirect() : void

Note that this function will exit the script (code that comes after it will not be executed).

Tags
since
1.0.0
Return values
void —

forward()

Forwards the request to another route.

forward() : void

Note that this function will exit the script (code that comes after it will not be executed).

Tags
since
1.0.0
Return values
void —

globals()

Returns an instance of the `Globals` class.

globals() : Globals
Tags
since
1.0.0
Return values
Globals —

session()

Returns an instance of the `Session` class.

session() : Session
Tags
since
1.3.0
Return values
Session —

flash()

Returns an instance of the `Flash` class.

flash() : object
Tags
see
Session::flash()
since
1.3.0
Return values
object —

csrf()

Returns an instance of the `CSRF` class.

csrf() : object
Tags
see
Session::csrf()
since
1.3.0
Return values
object —

database()

Returns an instance of the `Database` class.

database() : Database
Tags
since
1.3.0
Return values
Database —

auth()

Returns an instance of the `Auth` class.

auth() : Auth
Tags
since
1.4.0
Return values
Auth —

view()

Returns an instance of the `View` class.

view() : View
Tags
since
1.0.0
Return values
View —

render()

Renders a view (a Page wrapped in a Layout) with the passed variables, the Page content will be sent to `{view.defaultSectionName}` section.

render() : string
Tags
since
1.0.0
Return values
string —

render_layout()

Renders a theme layout with the passed variables.

render_layout() : string
Tags
since
1.0.0
Return values
string —

render_page()

Renders a theme page with the passed variables.

render_page() : string
Tags
since
1.0.0
Return values
string —

render_partial()

Renders a theme partial with the passed variables.

render_partial() : string
Tags
since
1.0.0
Return values
string —

section_push()

Pushes content to the buffer of the section with the given name.

section_push() : void

Note that a section will not be rendered unless it's yielded.

Tags
since
1.0.0
Return values
void —

section_reset()

Resets (empties) the buffer of the section with the given name.

section_reset() : void
Tags
since
1.0.0
Return values
void —

section_start()

Ends capturing buffer of the section with the given name. Works in conjunction with `self::sectionStart()`.

section_start() : void

Note that a section will not be rendered unless it's yielded.

Tags
since
1.0.0
Return values
void —

section_end()

Ends capturing buffer of the section with the given name. Works in conjunction with `self::sectionStart()`.

section_end() : void

Note that a section will not be rendered unless it's yielded.

Tags
throws
Exception

If no section has been started.

since
1.0.0
Return values
void —

section_yield()

Returns content of the section with the given name.

section_yield() : string
Tags
since
1.0.0
Return values
string —

include_file()

Includes a file from the active theme directory.

include_file() : void

Can also be used as a mean of extending a layout if it was put at the end of it.

Tags
since
1.0.0
Return values
void —

data()

Returns an instance of the `Data` class.

data() : Data
Tags
since
1.0.0
Return values
Data —

data_has()

Checks whether a value of a key exists in `self::$bag` via dot-notation.

data_has() : bool
Tags
since
1.0.0
Return values
bool —

data_get()

Gets a value of a key from `self::$bag` via dot-notation.

data_get() : mixed
Tags
since
1.0.0
Return values
mixed —

The requested value or null.

data_set()

Sets a value of a key in `self::$bag` via dot-notation.

data_set() : void
Tags
since
1.0.0
Return values
void —

html()

Returns an instance of the `HTML` class.

html() : HTML
Tags
since
1.0.0
Return values
HTML —

path()

Returns an instance of the `Path` class.

path() : Path
Tags
since
1.0.0
Return values
Path —

app_path_current()

Returns the current path, or compares it with the passed parameter. Note that the path does not contain the query string.

app_path_current() : string|bool
Tags
since
1.0.0
Return values
string|bool —

If null is passed, the current path as string. Otherwise the result of comparing the current path with the passed parameter as boolean.

app_url_current()

Returns the current URL, or compares it with the passed parameter.

app_url_current() : string|bool
Tags
since
1.0.0
Return values
string|bool —

If null is passed, the current URL as string. Otherwise the result of comparing the current URL with the passed parameter as boolean.

app_path()

Resolves the passed path to the app root path and returns it.

app_path() : string
Tags
since
1.0.0
Return values
string —

An absolute path on the server starting from app root.

app_url()

Resolves the passed path to the base URL (starting from app root) and returns it.

app_url() : string
Tags
since
1.0.0
Return values
string —

An absolute path on the server (public URL) starting from app root.

theme_path()

Resolves the passed path to the theme root path and returns it.

theme_path() : string
Tags
since
1.0.0
Return values
string —

A relative path starting from app root to the root of the active theme directory.

theme_url()

Resolves the passed path to the base URL (starting from active theme root) and returns it.

theme_url() : string
Tags
since
1.0.0
Return values
string —

An absolute path on the server (public URL) starting from active theme root.

assets_path()

Resolves the passed path to the assets directory and returns it.

assets_path() : string
Tags
since
1.0.0
Return values
string —

A relative path starting from app root to the root of the assets directory of the active theme directory.

assets_url()

Resolves the passed path to the base URL (starting from active theme assets root) and returns it.

assets_url() : string
Tags
since
1.0.0
Return values
string —

An absolute path on the server (public URL) starting from active theme root.

dd()

Dumps a variable and dies.

dd(mixed ...$variable) : void
Parameters
$variable : mixed
Tags
since
1.0.0
Return values
void —

The result will simply get echoed.

dump()

Dumps a variable in a nice HTML block with syntax highlighting.

dump(mixed ...$variable) : void
Parameters
$variable : mixed
Tags
since
1.0.0
Return values
void —

The result will simply get echoed.

dump_exception()

Dumps an exception in a nice HTML page or as string and exits the script.

dump_exception(Throwable $exception) : void
Parameters
$exception : Throwable
Tags
since
1.0.0
Return values
void —

The result will be echoed as HTML page or a string representation of the exception if the interface is CLI.

Search results