Luminova Framework

Base Application

Last updated: 2024-05-24 15:13:53

The Base Application serves as the foundational framework upon which your web application are built. It encapsulates essential functionalities, design patterns, and architectural principles that provide a solid starting point for developing complex applications. Essentially, the Base Application represents the core infrastructure and scaffolding upon which you can construct your application logic.

Your application class must be located in the /app/Controllers/ directory, and its name must remain unchanged under any circumstance.



Example

This is an example a basic application class may look like using the __construct method.

<?php
namespace App\Controllers;

use \Luminova\Base\BaseApplication;
class Application extends BaseApplication  
{
    public function __construct()
    {
        parent::__construct();
    }
}

Alternatively, this is an of application class may using the onCreate method.

<?php
namespace App\Controllers;

use \Luminova\Base\BaseApplication;
class Application extends BaseApplication  
{
    protected function onCreate(): void
    {
        //...
    }
}

Methods

The methods and properties of the base application are a combination of those inherited from the TemplateView, your Application, and the BaseApplication class. These classes ensure that properties and methods are accessible wherever the application object is invoked, based on their visibility. You can access them accordingly.

getInstance

The singleton getInstance method allows you to return a shared static instance of your application class.

public static final getInstance(): static

getView

The getView method allows you to the current view URI segments.

public final getView(): string

Return Value:

string - Returns current view URI segment.


Application Events

To handle command events in your application controller class based on actions, below are the list of events to listen to.


onCreate

The onCreate method in your application class serves as an alternative to the __construct() method. It is invoked after all necessary initializations have been performed, ensuring that your application is fully initialized before any operations are carried out on template views.

protected onCreate(): void

This method provides a convenient hook for executing additional setup logic or configurations specific to your application after the standard initialization process.


onFinish

Application on finish even, which triggers once application router has finished handling request.This trigger weather error occurs or not.

protected onFinish(): void

onFinish

Application on finish even, which triggers once application router has finished handling request.This trigger weather error occurs or not.

protected onFinish(): void

onContextInstalled

Application on context installed, which triggers once application route context has successfully registered request context.

protected function onContextInstalled(string $context): void

Parameters:

ParameterTypeDescription
$contextstringThe context name that was registered.

onViewPresent

Application on view presented event, which is triggered after view controller method was called.

protected function onViewPresent(string $uri): void

Parameters:

ParameterTypeDescription
$uristringThe view URI that was presented.

onCommandPresent

Application on command presented event, which is triggered after command controller was called.

protected function onCommandPresent(array $options): void

Parameters:

ParameterTypeDescription
$optionsarrayThe command options that was presented.