PHP Luminova: Luminova Framework Class
Luminova built-in development server, leveraging PHP's development server functionality. This is useful for development and testing your application in a controlled environment.
The Luminova class is the central utility hub for the Luminova framework. It provides framework-level constants and static helper methods to simplify common tasks, access the application kernel, and retrieve metadata about the framework.
All methods are static, so there’s no need to instantiate the class.
Usage Examples
Get Framework Version
use Luminova\Luminova;
echo Luminova::version(); // e.g., 3.8.1Access the Application Kernel
$kernel = Luminova::kernel();
// Use $kernel to access modules and servicesGet Base Class Name
$base = Luminova::getClassBaseName('\App\Controllers\HomeController');
// Returns: HomeControllerTrim System Path
$path = Luminova::trimSystemPath('/var/www/project/app/Controllers/Http/Home.php');
// Returns: app/Controllers/Http/Home.phpClass Definition
- Full namespace:
\Luminova\Luminova - This class is a Final class
Constants
| Constant | Type | Description |
|---|---|---|
VERSION | string | The current Luminova framework version. |
VERSION_NAME | string | The codename associated with the current Luminova version. |
MIN_PHP_VERSION | string | The minimum PHP version required to run Luminova. |
NOVAKIT_VERSION | string | The version of the built-in CLI Novakit. |
Methods
version
Get the framework version name or code.
final public static version(bool $integer = false): string|intParameters:
| Parameter | Type | Description |
|---|---|---|
$integer | bool | Return version code or version name (default: name). |
Return Value:
string|int - Return version name or code.
kernel
Get the application kernel instance.
Returns the kernel responsible for bootstrapping the applicationand providing access to core modules during the application lifecycle.
- By default, a shared kernel instance is returned.
- If
$notSharedis true, or the kernel is configured not to be shared, a new kernel instance is created and returned.
public static kernel(bool $notShared = false): Luminova\Interface\ServiceKernelInterfaceParameters:
| Parameter | Type | Description |
|---|---|---|
$notShared | bool | Force creation of a new kernel instance. |
Return Value:
\Luminova\Interface\ServiceKernelInterface - Kernel instance used to bootstrap the application.
For more information see Application Service Kernel documentation.
getBase
Returns the base public controller directory.
This strips the controller script name from SCRIPT_NAME and normalizesthe path using forward slashes.
public static getBase(): stringReturn Value:
string - Return the base path ending with a forward slash (e.g. /, /admin/).
toAbsoluteUrl
Convert a relative path to a full absolute URL.
Automatically removes system-relative parts like public/, and resolves base URLbased on the current environment (development vs production).
public static toAbsoluteUrl(string $path): stringParameters:
| Parameter | Type | Description |
|---|---|---|
$path | string | Relative file path to convert. |
Return Value:
string - Return fully qualified URL.
getUriSegments
Get the request url segments as relative.
Resolves the request URI as a relative path, without query string or base path.
public static getUriSegments(): stringReturn Value:
string - Return the normalized URI segment path (e.g., /products/view/10)
getSegments
Get the URI segments as an array.
Splits the request URI into individual segments.Automatically removes the "public" prefix if it appears at the start of the URI.
public static getSegments(): array<int,string>Return Value:
array<int,string> - Return an array of URI segments.
Examples:
- URI
/public/foo/bar→ Returns['foo', 'bar'] - URI
/public→ Returns[''] - URI
/products/view/10→ Returns['products', 'view', '10'] - URI
/→ Returns['']
getCacheId
Generate a unique URL based cache key for the current request.
This method creates a normalized identifier for caching based on:
- The HTTP request method (
GET,POST, etc.). - The request URI (path and optionally query parameters).
- Stripping file extensions for static cache formats if configured.
- Replacing special URL characters with dashes for safe storage.
The resulting string is hashed with MD5 to produce a fixed-length cache ID.
public static getCacheId(?string $salt = null, ?bool $uriQuery = null): stringParameters:
| Parameter | Type | Description |
|---|---|---|
$salt | string|null | Optional cache salt to include in key hashing (default: null). |
$uriQuery | ?bool | Whether to include query parameters in the cache ID (default: false).If set to null, it uses default from env(page.cache.query.params)If explicitly set, it overrides the default env. |
Return Value:
string - Return a unique MD5 hash representing the cache ID for this request.
isApiPrefix
Determine whether the current request targets the API.
A request is considered an API call if the first URI segment matches the configured API prefix (e.g, /api, public/api, a custom prefix from env(app.api.prefix)), or when enabled and request is an XMLHttpRequest.
public static isApiPrefix(?bool $ajaxAsApi = null): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$ajaxAsApi | bool|null | When true, treats XMLHttpRequest (AJAX) requests as API calls. If null, falls back to env(app.validate.ajax.asapi). |
Return Value:
bool - Returns true if the request matches the API prefix or qualifies as an AJAX request when enabled.
isCommand
Determines if the application is running in CLI (Command-Line Interface) mode.
public static isCommand(): boolReturn Value:
bool - Return true if running via CLI; false if it's a web request.
isCallable
Check if the given input can be called as a function or method.
This method detects standard callables, closures, function names, and array-style class/method pairs. If $strict is true, it will also verify that the class in an array callable exists.
public static isCallable(mixed $input, bool $strict = false): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$input | mixed | The value to check (string, array, closure, object, etc.). |
$strict | bool | If true, array callables are valid only if the class exists. |
Return Value:
bool - Return true if the input is callable, false otherwise.
trimSystemPath
Trim a file path to start from a known system directory.
This method removes any leading path segments before the first recognizedsystem directory (e.g., app, system). It's useful for hiding sensitiveserver directories when displaying errors, logs, or debugging information.
The returned path will always start from the first matched system directory.If no system directory is found in the path, the original path is returned.
public static trimSystemPath(string $path): stringParameters:
| Parameter | Type | Description |
|---|---|---|
$path | string | Full file path to filter. |
Return Value:
string - Return the trimmed path starting from a known system directory, or the original path if no match is found.
permission
Check if file has read or write permission is granted.
public static permission(string $permission = 'rw', ?string $file = null, bool $throw = false): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$permission | string | File access permission. |
$file | string|null | File name or file path to check permissions (default: writeable dir). |
$throw | bool | Indicate whether to throws an exception if permission is not granted. |
Return Value:
bool - Returns true if permission is granted otherwise false.
Throws:
- Luminova\Exceptions\FileException - If permission is not granted and quiet is not passed true.
isPropertyExists
Check whether a class or object has a property, with optional static-only filtering.
Uses ReflectionClass when $staticOnly is true to determine if a property is declared as static.For general use, it falls back to property_exists() for better performance.
public static isPropertyExists(class-string|object $objectOrClass, string $property, bool $staticOnly = false): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$objectOrClass | class-string|object | The class name or object to check. |
$property | string | The property name to check for. |
$staticOnly | bool | If true, only returns true for static properties (default: false). |
Return Value:
bool - Returns true if the property exists (and is static if required), false otherwise.
getClassBaseName
Get the base class name(s) from fully qualified class name(s).
Accepts:
- A single fully qualified class name (FQCN), e.g.
App\Controllers\HomeController - A comma-separated string of FQCNs, e.g.
App\Models\User, App\Services\Log - An array of FQCNs
Returns the base class name(s) while preserving the input format:
- Single string input → returns a single string
- Comma-separated string → returns a comma-separated string
- Array → returns an array of base names
public static getClassBaseName(array|string $class): array|stringParameters:
| Parameter | Type | Description |
|---|---|---|
$class | array<int,string>|string | One or more fully qualified class names. |
Return Value:
string - Return base class name(s), format matches the input.
Examples:
Luminova::getClassBaseName('\App\Controllers\HomeController');
// Returns: 'HomeController'
Luminova::getClassBaseName('App\Models\User, App\Services\Log');
// Returns: 'User, Log'
Luminova::getClassBaseName(['App\Models\User', 'App\Services\Log']);
// Returns: ['User', 'Log']