API Documentation (v0.9.0-alpha)

Avolutions\Core\Application

extends Container

This class is responsible for path and namespace management of the Application.

Properties

Property Visibility Type Description
$instances protected array An array of all instance of singleton classes
$resolvedEntries protected array Array to store resolved entries.

Methods

Method Visibility Description
__construct() public Creates a new Application instance.
get() public Finds an entry of the container by its identifier and returns it.
getAppPath() public Returns the application path.
getBasePath() public Returns the base path.
getCommandNamespace() public Returns the namespace for Command classes.
getCommandPath() public Returns the path where Commands are stored.
getCommandTemplatePath() public Returns the path where Command templates are stored.
getConfigPath() public Returns the path where config files are stored.
getControllerNamespace() public Returns the namespace for Controller classes.
getControllerPath() public Returns the path where Controllers are stored.
getDatabaseNamespace() public Returns the namespace for Database Migration classes.
getDatabasePath() public Returns the path where database migrations are stored.
getEventNamespace() public Returns the namespace for Event classes.
getEventPath() public Returns the path where Events are stored.
getInstance() public Returns an instance of the called class. If there is no instance so far, a new instance is created and returned. Otherwise, the existing one is returned (singleton).
getListenerNamespace() public Returns the namespace for Listener classes.
getListenerPath() public Returns the path where Listeners are stored.
getMappingPath() public Returns the path where mapping files are stored.
getModelNamespace() public Returns the namespace for Model classes.
getModelPath() public Returns the path where Models are stored.
getTranslationPath() public Returns the path where translation files are stored.
getValidatorNamespace() public Returns the namespace for Validator classes.
getValidatorPath() public Returns the path where Validators are stored.
getViewPath() public Returns the path where Views are stored.
has() public Returns false otherwise. `has($id)` returning true does not mean that `get($id)` will not throw an exception. It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
make() public Works like get(), but resolve the entry every time (create new instance). Also, parameters can be passed to the constructor.
set() public Set parameter values and alias definitions.
setErrorHandler() public Set error and exception handler for the Application.
setInstance() public Set the instance of the given class.
start() public Starts the Application by executing the Request, calling the Router to find the matching Route and invokes the controller action with passed parameters.

Property Details

$instances

An array of all instance of singleton classes

protected static array<string|int, mixed> $instances = []
$resolvedEntries

Array to store resolved entries.

protected array<string|int, mixed> $resolvedEntries = []

Method Details

__construct()

Creates a new Application instance.

public __construct(string $basePath[, array<string|int, mixed>|null $paths = [] ][, array<string|int, mixed>|null $namespaces = [] ]) : mixed
Parameters

string $basePath
The base path of your application.

array<string|int, mixed>|null $paths (optional)

array<string|int, mixed>|null $namespaces (optional)

get()

Finds an entry of the container by its identifier and returns it.

public get(string $id) : mixed
Parameters

string $id
Identifier of the entry to look for.

Return values
mixed Finds an entry of the container by its identifier and returns it.
getAppPath()

Returns the application path.

public getAppPath() : string
Return values
string Returns the application path.
getBasePath()

Returns the base path.

public getBasePath() : string
Return values
string Returns the base path.
getCommandNamespace()

Returns the namespace for Command classes.

public getCommandNamespace() : string
Return values
string Returns the namespace for Command classes.
getCommandPath()

Returns the path where Commands are stored.

public getCommandPath() : string
Return values
string Returns the path where Commands are stored.
getCommandTemplatePath()

Returns the path where Command templates are stored.

public getCommandTemplatePath() : string
Return values
string Returns the path where Command templates are stored.
getConfigPath()

Returns the path where config files are stored.

public getConfigPath() : string
Return values
string Returns the path where config files are stored.
getControllerNamespace()

Returns the namespace for Controller classes.

public getControllerNamespace() : string
Return values
string Returns the namespace for Controller classes.
getControllerPath()

Returns the path where Controllers are stored.

public getControllerPath() : string
Return values
string Returns the path where Controllers are stored.
getDatabaseNamespace()

Returns the namespace for Database Migration classes.

public getDatabaseNamespace() : string
Return values
string Returns the namespace for Database Migration classes.
getDatabasePath()

Returns the path where database migrations are stored.

public getDatabasePath() : string
Return values
string Returns the path where database migrations are stored.
getEventNamespace()

Returns the namespace for Event classes.

public getEventNamespace() : string
Return values
string Returns the namespace for Event classes.
getEventPath()

Returns the path where Events are stored.

public getEventPath() : string
Return values
string Returns the path where Events are stored.
getInstance()

Returns an instance of the called class. If there is no instance so far, a new instance is created and returned. Otherwise, the existing one is returned (singleton).

public final static getInstance() : object
Return values
object Returns an instance of the called class. If there is no instance so far, a new instance is created and returned. Otherwise, the existing one is returned (singleton).
getListenerNamespace()

Returns the namespace for Listener classes.

public getListenerNamespace() : string
Return values
string Returns the namespace for Listener classes.
getListenerPath()

Returns the path where Listeners are stored.

public getListenerPath() : string
Return values
string Returns the path where Listeners are stored.
getMappingPath()

Returns the path where mapping files are stored.

public getMappingPath() : string
Return values
string Returns the path where mapping files are stored.
getModelNamespace()

Returns the namespace for Model classes.

public getModelNamespace() : string
Return values
string Returns the namespace for Model classes.
getModelPath()

Returns the path where Models are stored.

public getModelPath() : string
Return values
string Returns the path where Models are stored.
getTranslationPath()

Returns the path where translation files are stored.

public getTranslationPath() : string
Return values
string Returns the path where translation files are stored.
getValidatorNamespace()

Returns the namespace for Validator classes.

public getValidatorNamespace() : string
Return values
string Returns the namespace for Validator classes.
getValidatorPath()

Returns the path where Validators are stored.

public getValidatorPath() : string
Return values
string Returns the path where Validators are stored.
getViewPath()

Returns the path where Views are stored.

public getViewPath() : string
Return values
string Returns the path where Views are stored.
has()

Returns false otherwise.

has($id) returning true does not mean that get($id) will not throw an exception. It does however mean that get($id) will not throw a NotFoundExceptionInterface.

public has(string $id) : bool
Parameters

string $id
Identifier of the entry to look for.

Return values
bool Returns false otherwise. `has($id)` returning true does not mean that `get($id)` will not throw an exception. It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
make()

Works like get(), but resolve the entry every time (create new instance). Also, parameters can be passed to the constructor.

public make(string $id[, array<string|int, mixed> $parameters = [] ]) : mixed
Parameters

string $id
Identifier of the entry to look for.

array<string|int, mixed> $parameters (optional)
Array of parameters to pass to constructor, where key is name of parameter

Return values
mixed Works like get(), but resolve the entry every time (create new instance). Also, parameters can be passed to the constructor.
set()

Set parameter values and alias definitions.

public set(string $name, mixed $value) : mixed
Parameters

string $name
Name of the entry.

mixed $value
Alias value or array of parameter values.

Return values
mixed Set parameter values and alias definitions.
setErrorHandler()

Set error and exception handler for the Application.

public setErrorHandler() : mixed
Return values
mixed Set error and exception handler for the Application.
setInstance()

Set the instance of the given class.

public final static setInstance(mixed $class) : void
Parameters

mixed $class
The class to set.

Return values
void Set the instance of the given class.
start()

Starts the Application by executing the Request, calling the Router to find the matching Route and invokes the controller action with passed parameters.

public start(Request $Request) : mixed
Parameters

Request $Request
Request instance.

Return values
mixed Starts the Application by executing the Request, calling the Router to find the matching Route and invokes the controller action with passed parameters.