Hazaar Constants
Hazaar Constants
Hazaar provides a comprehensive set of global constants that are available throughout your application. These constants help standardize values across the framework and provide essential configuration information, timing data, file handling options, and internal identifiers. Understanding these constants will help you build more robust applications and integrate more effectively with Hazaar's internal systems.
This reference documents all constants defined within the Hazaar framework's src directory, organized by their functional categories.
Application Constants
These constants provide essential information about the application environment and the Hazaar framework itself.
HAZAAR_VERSION
- Value:
'1.0' - Type: String
- Defined in: src/Application.php
The current version of the Hazaar framework. This constant is defined when the application is bootstrapped and can be used to check framework compatibility or display version information in your application.
HAZAAR_START
- Value: Microtime
- Type: Float
- Defined in: src/Application.php
A high-precision timestamp captured when the Hazaar framework begins execution. This constant is set using microtime(true) during application bootstrap and is useful for performance profiling, measuring total execution time, and debugging timing-related issues. The value represents Unix timestamp with microseconds as decimal fraction.
APPLICATION_ENV
- Value: Environment variable or
'development'(default) - Type: String
- Defined in: src/Application.php, src/Console/Application.php, src/Warlock/Agent/Runner.php
Specifies the current environment the application is running in (e.g., 'development', 'staging', 'production'). This constant is typically set via the APPLICATION_ENV environment variable in your web server configuration or command-line environment. If not set externally, it defaults to 'development'. This constant is used throughout the framework to determine environment-specific behaviors such as error reporting levels, caching strategies, and configuration loading.
APPLICATION_PATH
- Value: Path string from environment variable
- Type: String
- Defined in: src/Warlock/Agent/Runner.php
The absolute filesystem path to the application directory. This constant is used by Warlock agents to locate application files and is set from the APPLICATION_PATH environment variable. It's primarily used in background processes and scheduled tasks managed by the Warlock server.
APPLICATION_AUTOLOAD
- Value: Path string from environment variable
- Type: String
- Defined in: src/Warlock/Agent/Runner.php
The path to the Composer autoload file (autoload.php). This constant is used by Warlock agents to bootstrap the application's class autoloading system. The agent runner will verify this file exists before attempting to execute tasks.
Error Type Constants
These constants identify different types of errors and exceptions within the error handling system.
ERR_TYPE_ERROR
- Value:
0 - Type: Integer
- Defined in: src/Controller/Error.php
Identifies a standard PHP error that has been caught by the error handler. This includes warnings, notices, and other non-fatal errors that occur during script execution.
ERR_TYPE_EXCEPTION
- Value:
1 - Type: Integer
- Defined in: src/Controller/Error.php
Identifies an uncaught exception that has been passed to the exception handler. This is used to distinguish between regular errors and exceptional conditions that were thrown but not caught by application code.
ERR_TYPE_SHUTDOWN
- Value:
2 - Type: Integer
- Defined in: src/Controller/Error.php
Identifies a fatal error that occurred during script shutdown. These are typically critical errors that prevented normal script execution from completing, caught by the shutdown handler.
File Filter Constants
These constants are used with the Hazaar\File class to control content filtering operations when reading or writing files.
FILE_FILTER_IN
- Value:
0 - Type: Integer
- Defined in: src/File.php
Specifies that filters should be applied when reading content from a file. Input filters can decrypt, decompress, or otherwise transform data as it's read from storage.
FILE_FILTER_OUT
- Value:
1 - Type: Integer
- Defined in: src/File.php
Specifies that filters should be applied when writing content to a file. Output filters can encrypt, compress, or otherwise transform data before it's written to storage.
FILE_FILTER_SET
- Value:
2 - Type: Integer
- Defined in: src/File.php
Specifies that filters should replace the existing filter stack rather than being added to it. This allows you to completely redefine the filtering behavior for a file operation.
File Synchronization Constants
These constants are used by the Hazaar\File\Dir class to report synchronization status during directory sync operations.
HZ_SYNC_DIR
- Value:
1 - Type: Integer
- Defined in: src/File/Dir.php
Indicates that synchronization of a directory has started. This event is fired when the sync process begins processing a new directory.
HZ_SYNC_DIR_COMPLETE
- Value:
2 - Type: Integer
- Defined in: src/File/Dir.php
Indicates that synchronization of a directory has completed successfully. All files and subdirectories within have been processed.
HZ_SYNC_FILE
- Value:
3 - Type: Integer
- Defined in: src/File/Dir.php
Indicates that synchronization of a file has started. This event is fired when a file is about to be synchronized between source and destination.
HZ_SYNC_FILE_UPDATE
- Value:
4 - Type: Integer
- Defined in: src/File/Dir.php
Indicates that a file synchronization is in progress. This event may be fired multiple times during large file transfers to report progress.
HZ_SYNC_FILE_COMPLETE
- Value:
5 - Type: Integer
- Defined in: src/File/Dir.php
Indicates that synchronization of a file has completed successfully. The file has been fully transferred and verified.
HZ_SYNC_ERROR
- Value:
6 - Type: Integer
- Defined in: src/File/Dir.php
Indicates that an error occurred during synchronization. The sync process may continue with other files, but this particular operation failed.
Cron Index Constants
These constants are used by the Hazaar\Util\Cron class to access individual fields within a parsed cron expression.
IDX_MINUTE
- Value:
0 - Type: Integer
- Defined in: src/Util/Cron.php
Array index for the minute field in a cron expression (0-59). Used when parsing or accessing cron schedule components.
IDX_HOUR
- Value:
1 - Type: Integer
- Defined in: src/Util/Cron.php
Array index for the hour field in a cron expression (0-23). Used when parsing or accessing cron schedule components.
IDX_DAY
- Value:
2 - Type: Integer
- Defined in: src/Util/Cron.php
Array index for the day of month field in a cron expression (1-31). Used when parsing or accessing cron schedule components.
IDX_MONTH
- Value:
3 - Type: Integer
- Defined in: src/Util/Cron.php
Array index for the month field in a cron expression (1-12). Used when parsing or accessing cron schedule components.
IDX_WEEKDAY
- Value:
4 - Type: Integer
- Defined in: src/Util/Cron.php
Array index for the day of week field in a cron expression (0-6, where 0 is Sunday). Used when parsing or accessing cron schedule components.
IDX_YEAR
- Value:
5 - Type: Integer
- Defined in: src/Util/Cron.php
Array index for the optional year field in an extended cron expression. Used when parsing or accessing cron schedule components that include year specifications.
Metric File Constants
These constants are used by the Hazaar\File\Metric class for working with binary metric data files, similar to RRD (Round-Robin Database) files.
METRIC_FLOAT_LEN
- Value: Calculated from
strlen(pack('f', 0)) - Type: Integer
- Defined in: src/File/Metric.php
The byte length of a float value in the metric file format. This is calculated at runtime based on the system's float packing format.
METRIC_HDR_LEN
- Value:
8 - Type: Integer
- Defined in: src/File/Metric.php
The byte length of the main header in a metric file. This header contains version and configuration information.
METRIC_DSDEF_LEN
- Value:
12 + (2 * METRIC_FLOAT_LEN) - Type: Integer
- Defined in: src/File/Metric.php
The byte length of a data source definition in a metric file. Each data source definition describes a metric being tracked, including its name, type, and bounds.
METRIC_ARCHIVE_HDR_LEN
- Value:
18(plus ID length) - Type: Integer
- Defined in: src/File/Metric.php
The byte length of an archive header in a metric file. Archives define different resolution levels for storing aggregated metric data.
METRIC_PDP_HDR_LEN
- Value:
6 - Type: Integer
- Defined in: src/File/Metric.php
The byte length of a Primary Data Point (PDP) header. PDPs represent raw data points before aggregation.
METRIC_PDP_ROW_LEN
- Value:
METRIC_PDP_HDR_LEN + METRIC_FLOAT_LEN - Type: Integer
- Defined in: src/File/Metric.php
The total byte length of a complete PDP row, including both header and data value.
METRIC_CDP_HDR_LEN
- Value:
6 - Type: Integer
- Defined in: src/File/Metric.php
The byte length of a Consolidated Data Point (CDP) header. CDPs represent aggregated data points at different time resolutions.
METRIC_TYPE_HDR
- Value:
0xA1 - Type: Integer (Hexadecimal)
- Defined in: src/File/Metric.php
Type identifier for a metric file header section. Used when reading or writing the main file header.
METRIC_TYPE_DS
- Value:
0xA2 - Type: Integer (Hexadecimal)
- Defined in: src/File/Metric.php
Type identifier for a data source definition section. Used when reading or writing data source configurations.
METRIC_TYPE_AD
- Value:
0xA3 - Type: Integer (Hexadecimal)
- Defined in: src/File/Metric.php
Type identifier for an archive definition section. Used when reading or writing archive configurations.
METRIC_TYPE_PDP
- Value:
0xA4 - Type: Integer (Hexadecimal)
- Defined in: src/File/Metric.php
Type identifier for a Primary Data Point section. Used when reading or writing raw metric data points.
METRIC_TYPE_CDP
- Value:
0xA5 - Type: Integer (Hexadecimal)
- Defined in: src/File/Metric.php
Type identifier for a Consolidated Data Point section. Used when reading or writing aggregated metric data points.