BOSON Help

Application

The Boson\Application is the central component of the Boson and is responsible for managing the application lifecycle. It provides a single entry point for creating and managing web applications using WebView.

The application is responsible for:

...and more

Architecturally, the application, like most key components, is divided into two "layers":

  • The main functionality belonging to the application itself.

  • Facades over methods and properties of descendants for quick access to the main internal components of the core.

Creating

To create an application, simply create a new Boson\Application object. This will be sufficient for the vast majority of cases.

$app = new Boson\Application();

The application constructor also contains several optional arguments that you can pass explicitly if you wish.

The first optional argument is responsible for the Boson\ApplicationCreateInfo application settings and allows you to fine-tune the application's operation.

$config = new Boson\ApplicationCreateInfo( // application configuration options ); $app = new Boson\Application(info: $config);

The remaining optional parameters are responsible for passing external dependencies.

For example, the second argument takes an optional reference to an external Psr\EventDispatcher\EventDispatcherInterface event dispatcher to which all events within the application can be delegated.

$dispatcher = new Any\Vendor\PsrEventDispatcher(); $app = new Boson\Application(dispatcher: $dispatcher);

After creating the application, you will have access to the API to work with it, and after the necessary actions, the application will automatically start, unless otherwise specified.

Launching

The application can be started manually using the run() method.

$app = new Boson\Application(); $app->run();

Stopping

The application can be stopped at any time using the quit() method:

$app->quit();

To find out if the application is running, you can use the Application::$isRunning property, which returns true if the application is currently running.

$app = new Boson\Application(); // any code if ($app->isRunning === false) { $app->run(); }

Identifier

The Boson\ApplicationId is a unique identifier for each application instance. The identifier is needed to compare different applications for their equivalence.

To get application identifier use the Application::$id property.

$app = new Boson\Application(); echo 'ID: ' . $app->id;

An identifier is a value object and contains methods for comparison and conversion to scalars.

if ($app1->id->equals($app2->id)) { echo sprintf('The %s app is equals to %s app', $app1, $app2); }
06 June 2025