Luminova Framework

PHP Luminova: Autoload Modules and Composer Dependency

Last updated: 2025-12-28 23:29:10

Autoload dependencies, initialize core services, and access shared memory for HTTP and CLI environments.

The Luminova Boot module simplifies framework initialization by autoloading dependencies, including Composer libraries, and registering core services. It ensures global functions, constants, and third-party libraries are ready for use across your application.

Instead of manually requiring the Composer autoloader (/system/plugins/autoload.php), you can use Luminova’s Boot (/system/Boot.php). This automatically handles basic setup, including initialization and error handling.


Boot Shared Memory

Boot provides in-memory storage APIs to keep and share temporary data at runtime.For more details, see Boot Shared Memory.


Examples

Boot in HTTP Context

Initialize the HTTP environment and get the application instance:

use Luminova\Boot;

require_once __DIR__ . '/system/Boot.php';
$app = Boot::http();

Or initialize without retrieving the application instance:

use Luminova\Boot;

require_once __DIR__ . '/system/Boot.php';
Boot::init();

Boot in CLI Context

Initialize the framework for command-line usage:

use Luminova\Boot;

require_once __DIR__ . '/system/Boot.php';
Boot::cli();

Class Definition

  • Namespace: Luminova\Boot
  • Type: Final class, cannot be extended.

Methods

init

Initializes the HTTP environment for web and API applications.

Warms up the application, registers error handlers, and loads core modules.

public static init(): void

Similar to the http() method but does not return the application instance.

Usage:

use Luminova\Boot;

require_once __DIR__ . '/system/Boot.php';

Boot::init();

autoload

Initializes all required autoload modules.

Wrapper for warmup() and finish(). Loads core modules and prepares the application context without registering error handlers or configuring the CLI environment.

public static autoload(): void

Use this to ensure Composer and framework modules are available in the current context.

Usage:

use Luminova\Boot;

require_once __DIR__ . '/system/Boot.php';

Boot::autoload();

http

Prepares the HTTP environment for web and API applications.

Typically used in public/index.php. Ensures the application is warmed up, registers error handlers, and loads required core modules before returning the application instance.

public static http(): Luminova\Foundation\Core\Application|App\Application<Luminova\Foundation\Core\Application>

Returns

Luminova\Foundation\Core\Application|App\Application<Luminova\Foundation\Core\Application> - Return the application instance.

Usage:

// /public/index.php

use Luminova\Boot;

require_once __DIR__ . '/../system/Boot.php';

Boot::http()->router->context(...)->run();

cli

Prepares the CLI environment.

Intended for use in custom CLI scripts. Autoloads required files, enables error reporting, validates the SAPI type, defines CLI constants, and completes the bootstrapping process.

public static cli(): void

Usage:

// /bin/script.php

#!/usr/bin/env php
<?php
use Luminova\Boot;

require __DIR__ . '/system/Boot.php';

Boot::cli();

// Your cli implementation

warmup

Loads core modules and prepares the application environment.

Ensures constants, functions, error handlers, setting time zones, adjusting execution limits, configuring script behavior and loads core framework modules in the correct order. Also applies HTTP method spoofing early to ensure routing uses the correct request method.

public static warmup(): void

Note:

The warmup method is automatically called when the Boot class is loaded.You may not need to call this method again.


application

Get the shared application instance.

This provides a single, global access point to the the current Core Application singleton object.

public static application(): Luminova\Foundation\Core\Application|App\Application<Luminova\Foundation\Core\Application>

Return Value:

Luminova\Foundation\Core\Application|\App\Application<\Luminova\Foundation\Core\Application> - Returns the application instance.


defineCliStreams

Ensures CLI standard streams (STDIN, STDOUT, STDERR) are available.

If the constants are not already defined, this method safely opens the corresponding PHP streams using Boot::tryFopen() and defines them.

public static defineCliStreams(): void

Throws:

Luminova\Exceptions\RuntimeException - If any of the streams cannot be opened or defined.


tryFopen

Opens a file using fopen() with exception handling.

If the file can't be opened or an error occurs, a RuntimeException is thrown.

public static tryFopen(string $filename, string $mode): ?resource

Parameters:

ParameterTypeDescription
$filenamestringThe path to file.
$modestringFile access mode (e.g., r, w).

Return Value:

resource|null - Return a valid stream resource.

Throws:

Luminova\Exceptions\RuntimeException - If the file can't be opened.