Constant

VERSION

VERSION = '1.0.0' : string

The Omega framework version.

Properties

$appPath

$appPath : string

The custom application path defined by the developer.

Type

string — Holds the custom application path defined by developer.

$basePath

$basePath : string

The base path for the Omega installation.

Type

string — Holds the base path for the Omega installation.

$bootstrapPath

$bootstrapPath : string

The custom application path defined by the developer.

Type

string — Holds the custom application path defined by developer.

$configPath

$configPath : string

The custom configuration path defined by the developer.

Type

string — Holds the custom configuration path defined by the developer.

$databasePath

$databasePath : string

The custom database path defined by the developer.

Type

string — Holds the custom database path defined by the developer.

$environmentFile

$environmentFile : string

The environment file to load during bootstrapping.

Type

string — Holds the environment file to load during bootstrapping.

$environmentPath

$environmentPath : string

The custom environment path defined by the developer.

Type

string — Holds the custom environment path defined by the developer.

$langPath

$langPath : string

The custom language path defined by the developer.

Type

string — Holds the custom language path defined by the developer.

$publicPath

$publicPath : string

The custom public path defined by the developer.

Type

string — Holds the custom public path defined by the developer.

$storagePath

$storagePath : string

The custom storage path defined by the developer.

Type

string — Holds the custom storage path defined by the developer.

$app

$app : array

Application configuration.

Type

array<string, string> — Holds the application configuration.

$bindings

$bindings : array

Binding class.

Type

array<string, callable> — Holds an array of class alias to factory closure bindings.

$resolved

$resolved : array

Resolved class.

Type

array<string, mixed> — Holds an array of resolved class instances by alias.

$instances

$instances : static[]

Singleton instance.

Type

array<string|int, static> — Holds the singleton instances.

Methods

bootstrap()

bootstrap() : \Omega\Http\Response

Bootstrap the application.

This method starts and runs the Omega application. It handles the entire application lifecycle, including session management, configuration setup, routing, and processing HTTP requests.

Throws

\Throwable

If an error occurs during application execution.

Returns

\Omega\Http\Response —

Return an instance of Response representing the application's response.

getVersion()

getVersion() : string

Get the version of the application.

Returns

string —

Return the version of the application.

getAppPath()

getAppPath(string  $path = '') : string

Get the path to the application 'app' directory.

Parameters

string $path

Holds the application 'app' path.

Returns

string —

Return the path for 'app' directory.

getBasePath()

getBasePath(string  $path = '') : string

Get the base path of the Omega installation.

Parameters

string $path

Holds the application path.

Returns

string —

Return the path of Omega installation.

getBootstrapPath()

getBootstrapPath(string  $path = '') : string

Get the path to the bootstrap directory defined by the developer.

Parameters

string $path

Holds the custom bootstrap path defined by the developer.

Returns

string —

Return the path for bootstrap directory.

getConfigPath()

getConfigPath(string  $path = '') : string

Get the path to the configuration directory defined by the developer.

Parameters

string $path

Holds the custom configuration path defined by the developer.

Returns

string —

Return the path for the configuration path.

getDatabasePath()

getDatabasePath(string  $path = '') : string

Get the path to the database directory defined by the developer.

Parameters

string $path

Holds the custom database path defined by the developer.

Returns

string —

Return the path for the database files.

environment()

environment(string|array  ...$environments) : string|bool

Get or check the current application environment.

Parameters

string|array $environments variadic

One or more environment names to check against the current environment.

If no parameters are provided, the method returns the current environment as a string. If one or more environment names are provided, the method returns true if the current environment matches any of the provided names; otherwise, it returns false.

Returns

string|bool —

The current environment as a string if no parameters are provided; true or false if checking against the provided environments.

getEnvironmentFile()

getEnvironmentFile() : string

Get the environment file the application is using.

Returns

string —

Return the environment file the application using.

getEnvironmentFilePath()

getEnvironmentFilePath() : string

Get the fully qualified path to the environment file.

Returns

string —

Return the fully qualified path to the environment file.

getEnvironmentPath()

getEnvironmentPath() : string

Get the path to the environment file directory.

Returns

string —

Return the path to the environment file directory.

getLangPath()

getLangPath(string  $path = '') : string

Get the path to the language directory defined by the developer.

Parameters

string $path

Holds the custom language path defined by the developer.

Returns

string —

Return the path to the language file directory.

getPublicPath()

getPublicPath(string  $path = '') : string

Get the path to the public/web directory defined by the developer.

Parameters

string $path

Holds the custom public/web path defined by the developer.

Returns

string —

Return the path to the public/web path directory.

getResourcePath()

getResourcePath(string  $path = '') : string

Get the path to the resources directory.

Parameters

string $path

Holds the application resources path.

Returns

string —

Return the path to the resources path directory.

getStoragePath()

getStoragePath(string  $path = '') : string

Get the path to the storage directory.

Parameters

string $path

Holds the storage path.

Returns

string —

Return the path to the storage path directory.

setAppPath()

setAppPath(string  $path) : $this

Set the application directory.

Parameters

string $path

Holds the path to set.

Returns

$this —

setBasePath()

setBasePath(string  $basePath) : $this

Set the base path for Omega installation.

Parameters

string $basePath

Holds the application path.

Returns

$this —

setBootstrapPath()

setBootstrapPath(string  $path) : $this

Set bootstrap file directory path.

Parameters

string $path

Holds the application path.

Returns

$this —

setConfigPath()

setConfigPath(string  $path) : $this

Set the configuration directory path.

Parameters

string $path

Holds the application path.

Returns

$this —

setDatabasePath()

setDatabasePath(string  $path) : $this

Set the database directory path.

Parameters

string $path

Holds the application path.

Returns

$this —

setEnvironmentFile()

setEnvironmentFile(string  $file) : $this

Set the environment file to be loading during bootstrapping.

Parameters

string $file

Holds the environment file to be loading during bootstrapping.

Returns

$this —

setEnvironmentPath()

setEnvironmentPath(string  $path) : $this

Set the environment directory path.

Parameters

string $path

Holds the application path.

Returns

$this —

setLangPath()

setLangPath(string  $path) : $this

Set the lang directory path.

Parameters

string $path

Holds the application path.

Returns

$this —

setPublicPath()

setPublicPath(string  $path) : $this

Set the public directory path.

Parameters

string $path

Holds the application path.

Returns

$this —

setStoragePath()

setStoragePath(string  $path) : $this

Set the storage directory path.

Parameters

string $path

Holds the application path.

Returns

$this —

isLocal()

isLocal() : bool

Determine if the application is in rhe local environment.

Returns

bool —

Return true if the application is in local environment.

isProduction()

isProduction() : bool

Determine if the application is in the production environment.

Returns

bool —

Return true if the application is in the production environment.

detectEnvironment()

detectEnvironment(\Closure  $callback) : string

Detect the application's current environment.

Parameters

\Closure $callback

Returns

string —

getJoinPaths()

getJoinPaths(string|null  $basePath, string  $path = '') : string

Join the given paths.

Parameters

string|null $basePath

Holds the base path to join.

string $path

Holds the path to join.

Returns

string —

Return the joined paths.

joinPaths()

joinPaths(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.

setCurrentTimeZone()

setCurrentTimeZone() : $this

Sets the default timezone for the application.

Returns

$this —

Returns a reference to the current object for method chaining.

getCurrentTimeZone()

getCurrentTimeZone() : string

Gets the current date and time formatted according to the application timezone.

Returns

string —

The formatted current date and time.

has()

has(string  $alias) : bool

Determine if the container has a binding for the given alias.

Parameters

string $alias

The class alias or key to check.

Returns

bool —

Returns true if the alias exists in the container bindings, false otherwise.

get()

get(string  $alias) : mixed

Retrieve an instance from the container by alias.

Parameters

string $alias

The class alias or key.

Throws

\Omega\Container\Exception\KeyNotFoundException

if the alias is not found in the container.

Returns

mixed —

The resolved class instance.

alias()

alias(string  $alias, callable  $factory) : $this

Bind the class.

Parameters

string $alias

Holds the class alias or key.

callable $factory

Holds a closure that defines how to create the class instance.

Returns

$this —

resolve()

resolve(string  $alias) : mixed

Resolve the container.

Parameters

string $alias

Holds the class alias or key.

Throws

\Omega\Container\Exception\KeyNotFoundException

if the key is not bound.

Returns

mixed —

Return the resolved class instance.

call()

call(callable|array{0: object|string, 1: string}  $callable, array  $parameters = []) : mixed

Call a callable with dependency injection.

Parameters

callable|array{0: object|string, 1: string} $callable

Holds the callable function or method.

array $parameters

Holds an associative array of additional parameters to pass.

Throws

\ReflectionException

if the callable cannot be reflected.

\Omega\Container\Exception\DependencyResolutionException

if a dependency cannot be resolved.

\InvalidArgumentException

if the callable is not invocable.

Returns

mixed —

Return the result of the callable.

remove()

remove(string  $alias) : bool

Remove the binding for the given alias.

Parameters

string $alias

The class alias or key to remove.

Returns

bool —

Returns true if the alias was found and removed, false otherwise.

clear()

clear() : void

Clear all bindings from the container.

This method removes all registered aliases and resolved instances.

Returns

void —

getBindings()

getBindings() : array<string,callable>

Get all bindings from the container.

Returns

array

Returns an array of all registered bindings.

getInstance()

getInstance(string|null  $basePath = null) : static

Get the singleton instance.

This method returns the singleton instance of the class. If an instance doesn't exist, it creates one and returns it.

Parameters

string|null $basePath

Holds the Omega application base path or null.

Returns

static —

Return the singleton instance.

__clone()

__clone() : void

Clone method.

This method is overridden to prevent cloning of the singleton instance. Cloning would create a second instance, which violates the Singleton pattern.

Throws

\Omega\Support\Singleton\Exception\SingletonException

If an attempt to clone the singleton is made.

Returns

void —

__wakeup()

__wakeup() : void

Wakeup method.

This method is overridden to prevent deserialization of the singleton instance. Deserialization would create a second instance, which violates the Singleton pattern.

Throws

\Omega\Support\Singleton\Exception\SingletonException

If an attempt at deserialization is made.

Returns

void —

__sleep()

__sleep() : array

Sleep method.

This method is overridden to prevent serialization of the singleton instance. Serialization would create a second instance, which violates the Singleton pattern.

Throws

\Omega\Support\Singleton\Exception\SingletonException

If an attempt at serialization is made.

Returns

array —

Return the names of private properties in parent classes.

__construct()

__construct(string|null  $basePath = null) : void

Application class constructor.

Parameters

string|null $basePath

Holds the Omega application base path or null.

Returns

void —

configure()

configure(string  $basePath) : void

Configure the application.

This method sets up the application's configuration by loading environment variables from Dotenv.

Parameters

string $basePath

Holds the base path of the application.

Returns

void —

bindProviders()

bindProviders() : void

Bind providers to the application.

This method binds service providers to the application, allowing them to register services and perform any necessary setup.

Returns

void —

registerFacades()

registerFacades() : void

Register the facades wth the application.

Returns

void —

dispatch()

dispatch(string  $basePath) : \Omega\Http\Response

Dispatch the application.

This method dispatches the application, including routing setup and handling of HTTP requests.

Parameters

string $basePath

The base path of the application.

Throws

\Throwable

If an error occurs during dispatching.

Returns

\Omega\Http\Response —

An instance of Response representing the application's response.

getReflector()

getReflector(callable|array{0: object|string, 1: string}  $callable) : \ReflectionMethod|\ReflectionFunction

Get reflector for the given callable.

Parameters

callable|array{0: object|string, 1: string} $callable

Holds the callable function or method.

Throws

\ReflectionException

if the callable cannot be reflected.

\InvalidArgumentException

if an unsupported callable type is provided.

Returns

\ReflectionMethod|\ReflectionFunction —

Return the reflection object for the callable.