System
in package
Weaver Framework - System Class
This class provides common system-related tasks such as error handling, logging, and environment variable loading.
Table of Contents
Methods
- displayErrorPage() : void
- Display an error page with a stack trace.
- loadEnvironmentVariables() : void
- Load Configuration from a .env File and Define Constants.
- loadModel() : object|null
- Load a model class dynamically.
- logError() : void
- Logs an error message to an error log file with a timestamp.
Methods
displayErrorPage()
Display an error page with a stack trace.
public
static displayErrorPage(Exception_ $exception) : void
Parameters
- $exception : Exception_
-
The exception to display.
loadEnvironmentVariables()
Load Configuration from a .env File and Define Constants.
public
static loadEnvironmentVariables([string $filePath = 'Configurations/.env' ]) : void
This method reads a .env file and defines constants for environment variables. If the .env file is not found, default values are used for these constants. If a constant is already defined, it will not be overridden.
Parameters
- $filePath : string = 'Configurations/.env'
-
The path to the .env file. Defaults to 'Configurations/.env'.
loadModel()
Load a model class dynamically.
public
static loadModel(string $modelName) : object|null
Parameters
- $modelName : string
-
The name of the model to load (without the .php extension).
Return values
object|null —An instance of the loaded model or null if the model file is not found.
logError()
Logs an error message to an error log file with a timestamp.
public
static logError(string $errorMessage) : void
Parameters
- $errorMessage : string
-
The error message to log.