Luminova Framework

PHP Luminova: Global Defined Constants

Last updated: 2026-08-29 15:55:58

Constants defines fixed values for application path, database return & result modes, and other application flags. Constants are immutable values set once and remain unchanged at runtime.

Global constants are fixed values defined once and used throughout the application. They provide consistent, unchangeable references that improve reliability and make your code easier to understand and maintain.

What Are Constants?

  • Immutable: Once defined, they cannot be changed during execution.
  • Global: Accessible from anywhere in your application.
  • Purposeful: Ideal for storing configuration flags, environment states, directory paths, status codes, or commonly reused values.

Using well-named constants reduces magic numbers and strings, making code more readable and self-explanatory.

For user-defined global functions and constants, see User Global Constants. > Luminova loads these during bootstrapping, making your custom functions and constants globally accessible throughout the application.


Scope and Usage

In Luminova, constants are typically declared in:

// /bootstrap/constants.php

This file is loaded early in the application lifecycle, ensuring your constants are available globally — before controllers, models, or routes are executed.


Default Constants

These are predefined constants provided by Luminova. They are automatically derived from your application's configuration and environment settings. These constants give global access to important values such as file paths, URLs, environment modes, and application metadata, making it easier to reference them across your project without repeating logic.


Application

ConstantTypeDescription
APP_NAMEstringApplication name or identifier.
APP_VERSIONstringApplication current version (e.g., 1.0.0).
APP_FILE_VERSIONstringStatic file version used for cache busting (e.g., v=1689123091).
APP_HOSTNAMEstringApplication hostname (e.g., example.com).
APP_HOSTNAME_ALIASstringAlternate hostname, typically the www version (e.g., www.example.com).
APP_URLstringFull application base URL (e.g., https://example.com).
APP_URL_ALIASstringFull alternate URL with alias domain (e.g., https://www.example.com).
APP_ROOTstringProject root directory (private folder containing core application code).

Environment

ConstantTypeDescription
ENVIRONMENTstringCurrent application environment type (development, production, testing, staging, etc.).
DOCUMENT_ROOTstringPublic document root (public folder accessible via web server).
STAGINGboolIndicates if the application is running in staging mode (ENVIRONMENT === 'staging').
PRODUCTIONboolIndicates if the application is running in production mode. Also true when STAGING is true, since staging is treated as production for features that should apply to production-like environments.
MAINTENANCEboolIndicates if the application is in maintenance mode.
CLI_ENVIRONMENTstringCLI-specific environment state for command-line operations. Only defined when running in a CLI context (PHP_SAPI === 'cli').

Status Codes

ConstantTypeDescriptionRecommended When
STATUS_SUCCESSintIndicates the operation was successful.When you want to continue the normal application flow after a successful process.
STATUS_ERRORintIndicates the operation failed.When a critical error occurs and the current process should stop or return an error response.
STATUS_SILENCEintIndicates the operation may have failed but was handled gracefully.When you want to suppress the error, return custom error details, or continue without showing a failure message.

I/O Streams

ConstantTypeDescription
STDOUTresourceStandard output stream handle, opened via php://stdout. Used for writing output (e.g., with fwrite).
STDINresourceStandard input stream handle, opened via php://stdin. Used to read input from CLI (e.g., with fgets).
STDERRresourceStandard error stream handle, opened via php://stderr. Used for writing error messages separately from standard output.

Note: These constants are only defined when the application is running in a CLI context (PHP_SAPI === 'cli'), if not already defined by PHP.


Template Rendering

ConstantTypeDescription
ALLOW_ACCESSboolIndicates that a template view file is being loaded by the view rendering engine. Allows a template view file to prevent direct access outside the rendering engine.

Database Fetch Modes

The FETCH_* constants define how individual rows are fetched from a query result.They are consistently supported across both PDO and MySQLi drivers in methods that allow specifying a fetch mode.

ConstantDescription
FETCH_ASSOCFetch row as an associative array, using column names as keys.
FETCH_NUMFetch row as a numerically indexed array, using column positions.
FETCH_BOTHFetch row as both associative and numeric array (default for many drivers).
FETCH_OBJFetch row as a standard object, where columns become object properties.
FETCH_COLUMNFetch a single column value from each row (indexed by row number).
FETCH_KEY_PAIRFetch a 2-column result as a key-value array. The first column becomes the key, the second the value.
FETCH_CLASSFetch row as an instance of a user-defined class, mapping columns to properties.

Tip:

  • Use FETCH_ASSOC for clean array access like $row['email'].
  • Use FETCH_OBJ or FETCH_CLASS when working with object-oriented access.
  • FETCH_KEY_PAIR is ideal for dropdown lists or ID-to-name mappings.

Database Result Return Modes

The following RETURN_* constants define how query results are returned.They are supported consistently across both PDO and MySQLi drivers and are mainly used with the fetch() and getResult() methods.

ConstantDescription
RETURN_ALLReturns all rows as an array or object (supports both fetch() and getResult()).
RETURN_NEXTReturns the next row or a single record as an array or object (supports both).
RETURN_STREAMEnables row-by-row iteration (streaming mode). Use inside a while loop (supports both).
RETURN_2D_NUMReturns all rows as a 2D array of numeric indexes (supports getResult() only).
RETURN_IDReturns the last inserted ID (supports getResult() only).
RETURN_INTReturns the record count of the current result set (supports getResult() only).
RETURN_COUNTReturns the number of affected rows (e.g., after UPDATE, DELETE) (supports getResult() only).
RETURN_COLUMNReturns all values of a single column (supports getResult() only).
RETURN_STMTReturns the prepared statement object (useful for manual execution or advanced operations) (supports getResult() only).
RETURN_RESULTReturns the raw result object (mysqli_result or PDOStatement) (supports getResult() only).

Tip:Use RETURN_ALL for full result sets, RETURN_NEXT for single records, and RETURN_STREAM for efficient memory usage in large datasets.


Database Param Types

The following PARAM_* constants are shared between PDO and MySQLi and standardize the way values are bound to prepared statements:

ConstantTypeDescription
PARAM_NULLintNull value type (e.g., for SQL NULL values).
PARAM_INTintInteger value type (e.g., for IDs, counters).
PARAM_STRintString value type (e.g., for text, UUIDs, dates).
PARAM_LOBintLarge object type (e.g., BLOBs or binary data).
PARAM_BOOLintBoolean value type (true or false).
PARAM_FLOATintFloating-point number (e.g., decimals).

Type Mapping

This table shows how each PARAM_* constant maps to native types in PDO and MySQLi drivers:

ConstantMeaningPDO EquivalentMySQLi Equivalent
PARAM_NULLNull valuePDO::PARAM_NULL's'
PARAM_INTIntegerPDO::PARAM_INT'i'
PARAM_STRStringPDO::PARAM_STR's'
PARAM_LOBLarge object/BLOBPDO::PARAM_LOB's'
PARAM_BOOLBooleanPDO::PARAM_BOOL'i'
PARAM_FLOATFloat (cast as string in PDO)PDO::PARAM_STR'd'

Note: PDO does not natively support float types, so PARAM_FLOAT is internally cast to string (PDO::PARAM_STR).


Others

ConstantTypeDescription
TRIM_DSstringDirectory separator characters (/\\) used when trimming directory paths.
URL_SCHEMEstringURL scheme (http or https) used by the application.
SHOW_DEBUG_BACKTRACEboolIndicates whether debug backtrace output is enabled.