\

Namespaces

Omega

Functions

app()

app(string|null  $alias = null) : mixed

Get an instance of the Omega Application.

Parameters

string|null $alias

Holdds the instance alias or null to get the main application instance.

Returns

mixed —

Returns the resolved instance or the main application instance if no alias is provided.

config()

config(string|null  $key = null, mixed  $default = null) : mixed

Alias or set a configuration value.

Parameters

string|null $key

Holds the configuration key or null to get the entire configuration.

mixed $default

Holds the default value if the key is not found.

Returns

mixed —

Returns the configuration value or the entire configuration if no key is provided.

csrf()

csrf() : string

Set the CSRF token.

Generates a CSRF token and stores it in the session.

Throws

\Exception

if session is not enabled.

Returns

string —

Returns the generated CSRF token.

dd()

dd(mixed  ...$params) : void

Dump variables and end script execution.

Parameters

mixed $params variadic

The variables to be dumped.

Returns

void —

dump()

dump(array  $array) : void

Display a variable dump in a formatted manner.

Parameters

array $array

The array to be dumped.

Returns

void —

env()

env(string  $key, mixed  $default = null) : mixed

Get the value of an environment variable.

Parameters

string $key

Holds the key of the environment variable.

mixed $default

Holds the default value if the key is not set.

Returns

mixed —

Returns the value of the environment variable or the default value if the key is not set.

get_base_path()

get_base_path() : string|null

Get the base path of the application.

Returns

string|null —

Returns the base path or null if not set.

get_config_path()

get_config_path(string|null  $path = '') : string

Get the path to the configuration directory.

Parameters

string|null $path

(Optionally) Holds the path to append config path.

Returns

string —

Return the path to the config folder.

get_database_path()

get_database_path(string|null  $path = '') : string

Get the path to the appropriate database migrations.

Parameters

string|null $path

(Optionally) Holds the path to append database path.

Returns

string —

Return the path to the database folder.

get_operating_system()

get_operating_system() : string

Get the operating system name.

Retrieves the operatingsystem name (e.g. mac, windows, linux or unknown).

Returns

string —

Returns the operating system name (e.g., "mac", "windows", "linux", or "unknown").

get_resource_path()

get_resource_path(string|null  $path = '') : string

Get the path to the resource folder.

Parameters

string|null $path

(Optionally) Holds the path to append resource path.

Returns

string —

Return the path to the resource folder.

get_storage_path()

get_storage_path(string|null  $path = '') : string

Get the path to the storage folder.

Parameters

string|null $path

(Optionally) Holds the path to append storage path.

Returns

string —

Return the path to the storage folder.

head()

head(array  $array) : mixed

Get the first element of an array.

Parameters

array $array

Holds the array to get the first element.

Returns

mixed —

join_paths()

join_paths(string|null  $basePath, string  ...$paths) : string

Join the given path.

Concatenates a base path with additional paths and returns the result.

Parameters

string|null $basePath

Holds the base path to join.

string $paths variadic

Holds the paths to join.

Returns

string —

Return the joined paths.

normalize_path()

normalize_path(string  $path) : ?string

Normalize path based on filesystem type.

Parameters

string $path

Holds the path to normalize.

Returns

?string —

Return the path normalized path based on operating system.

now()

now() : string

Returns the current date and time in the configured timezone.

Returns

string —

Return the formatted time zone.

redirect()

redirect(string  $url) : mixed

Redirect to a specific URL.

Redirects to a specified URL and return the result of the redirect session if no key is provided.

Parameters

string $url

Holds the URL to redirect to.

Returns

mixed —

Return that result of the redirect operation.

response()

response() : mixed

Get the response instance.

Returns

mixed —

Returns the response instance.

secure()

secure() : void

Secure the CSRF token.

Compares the CSRF token from the session with the one submitted in the POST data.

Throws

\Exception

if session is not enabled or CSRF token mismatch.

Returns

void —

session()

session(string|null  $key = null, mixed  $default = null) : mixed

Get or set a session value.

Parameters

string|null $key

Holds the session key or null to get the entire session.

mixed $default

Holds the default value if the key is not found.

Returns

mixed —

Returns the session value or the entire session if no key is provided.

validate()

validate(array  $data, array  $rules, string  $sessionName = 'errors') : mixed

Validate input.

Validates input data against specified rules.

Parameters

array $data

Holds an array of data to validate.

array $rules

Holds an array of rules.

string $sessionName

Holds the session name for storing validation errors.

Returns

mixed —

Returns the validation result.

value()

value(mixed  $value, mixed  ...$args) : mixed

The default value of the given value.

Parameters

mixed $value

Holds the value to check.

mixed $args variadic

Holds additional arguments if $values is a Closure.

Returns

mixed —

Returns the default value or the result of the Closure if $value is a Closure.