Luminova Framework

PHP Luminova: Application Factory Modules Management

Last updated: 2026-11-28 20:57:12

Create or reuse framework objects by their registered factory names.

Factory is a utility class in the Luminova framework designed to simplify the management of class instances across the Luminova codebase. It serves as a centralized hub, allowing the management of shared instances of classes throughout the framework.

Unlike the Services utility, Factory does not require configuration or registering classes. Class registration is defined within the Factory class and ready to be initialized when needed. Additionally, Factory does not support initializing classes by fully qualified class name (e.g., SomeClass::class), you must initialize using the predefine names.


Usages

To dynamically create an instance of a factory class, you can use the Factory::methodName().

use Luminova\Foundation\Module\Factory;
$instance = Factory::cookie('foo', 'foo-value', [], true);

Global Helper Function

Additionally, there is a namespaced helper function Luminova\Funcs\factory() available, which provides a convenient way to access factory instances.

use function Luminova\Funcs\factory;

$instance = factory('cookie', true, 'foo', 'foo-value', []);

Class Definition

  • Full namespace: Luminova\Foundation\Module\Factory
  • This class is final.

Methods

has

Check if class is available in factories

public static function has(string $factory): bool

Parameters:

ParameterTypeDescription
$factorystringThe factory name.

Return:

bool - Returns true if the name is registered in the factory map.


delete

Delete a shared instance of factory class.

public static function delete(string $factory): bool

Parameters:

ParameterTypeDescription
$factorystringThe factory name.

Return:bool - Return true if shared instance was deleted, false otherwise.


clear

Clear all shared instance of factory.

public static function clear(): void

For the application logger and HTTP client, see the service kernel. For other application services, see Service instances.

service

Return shared service class instance.

public static function service(): Service

Return:

Luminova\Foundation\Module\Service - Return instance of service class


Factory Names

The following dynamic calls forward their constructor arguments to the indicated class. A direct call uses an optional trailing boolean for sharing. The factory() helper takes the sharing flag before constructor arguments.

session

Server-side user session class.

public static function session(?Luminova\Interface\SessionManagerInterface $manager = null, bool $shared = true): Luminova\Sessions\Session

Parameters:

ParameterTypeDescription
$paramsSessionManagerInterface|nullSession storage interface.
$sharedboolWhether to return a shared instance. Default is true.

Return Value

Session - Instance of the server-side user session class.


Client-side cookie class.

public static function cookie(string $name, mixed $value = '', CookieConfig|array $options = [], bool $shared = true): Luminova\Cookies\Cookie

Parameters:

ParameterTypeDescription
$namestringCookie name.
$valuestringCookie value.
$optionsarray<array-key, mixed>Optional cookie options.
$sharedboolWhether to return a shared instance. Default is true.

Return Value

Cookie - Instance of the client-side cookie class.


task

Time task utility class.

public static function task(bool $shared = true): Luminova\Time\Task

Parameters:

ParameterTypeDescription
$sharedboolWhether to return a shared instance. Default is true.

Return Value

Task - Instance of the time task utility class.


language

Application translation class.

public static function language(?string $locale = null, bool $shared = true): Luminova\Components\Languages\Translator

Parameters:

ParameterTypeDescription
$localestring|nullLocale for translation.
$sharedboolWhether to return a shared instance. Default is true.

Return Value

Translator - Instance of the application translation class.


filesystem

File manager class.

public static function filesystem(bool $shared = true): Luminova\Storage\Filesystem

Parameters:

ParameterTypeDescription
$sharedboolWhether to return a shared instance. Default is true.

Return Value

FileManager - Instance of the file manager class.


validate

Input validation class.

public static function validate(bool $shared = true): Luminova\Security\Validation

Parameters:

ParameterTypeDescription
$sharedboolWhether to return a shared instance. Default is true.

Return Value

Validation - Instance of the input validation class.


response

Render response class.

public static function response(string|array|object|null $content = null, int $status = 200, array $headers = [], bool $shared = true): Luminova\Template\Response

Parameters:

ParameterTypeDescription
$contentstring&#124;array<array-key, mixed>&#124;object&#124;nullOptional response content (default null).
$statusintHTTP response status code (default 200).
$headersarray<string, mixed>Response header map (default []).
$sharedboolWhether to return a shared instance. Default is true.

Return Value

Response - Instance of the render response class.


request

HTTP Request class.

public static function request(bool $shared = true): Luminova\Http\Request

Parameters:

ParameterTypeDescription
$sharedboolWhether to return a shared instance. Default is true.

Return Value

Request - Instance of the HTTP Request class.


caller

This method can be used to call all methods withing a giving class class or list all extenders.

public static function caller(bool $shared = true): Luminova\Foundation\Module\Caller

Parameters:

ParameterTypeDescription
$sharedboolWhether to return a shared instance. Default is true.

Return Value

Caller - Instance of the Caller class.


Other factory names

NameClassConstructor arguments
escaperLuminova\Security\EscaperOptional encoding, default utf-8.
renderer, fileResponseLuminova\Storage\RendererStorage directory, then optional ETag and weak ETag flags.
notificationLuminova\Notifications\Firebase\NotificationOptional service account configuration, default ServiceAccount.json.