Raydium Framework

Configs
in package
implements ConfigsInterface Uses WhitelistTrait

Interfaces, Classes, Traits and Enums

ConfigsInterface

Table of Contents

$config  : mixed
Configuration array used by the application.
$appPath  : string
The absolute path to the application directory.
$configCache  : array<string|int, mixed>
Cache for loaded configurations.
$configsPath  : string
The absolute path to the application configurations directory.
$defaultMiddlewares  : array<string|int, mixed>
Default middlewares applied to the application.
$defaultWhitelist  : array<string|int, mixed>
Default whitelist settings for the application.
$frameworkConfigsPath  : string
The absolute path to the framework's configuration files.
__construct()  : mixed
Constructor for the configuration manager.
addConfig()  : void
app()  : static
Loads the `app` options separately to avoid side effects.
appOptions()  : array<string|int, mixed>
clearConfigCache()  : void
Clear the configuration cache or optionally for a specific key.
dbAdminer()  : void
Load the Adminer script.
defaultConfigPath()  : mixed
envTenantId()  : string|null
get()  : mixed
getActivePlugins()  : mixed
getAppPath()  : mixed
getConfig()  : DotAccess|null
Get a loaded configuration by key.
getConfigsDir()  : mixed
getDefault()  : array<string|int, null|mixed|(null|bool|mixed|(null|bool|int|mixed|string|string[])[]|string)[]>
getTenantFilePath()  : null|array<string|int, null|mixed|(null|bool|mixed|(null|false|int|mixed|string)[]|string)[]|string>|string
Retrieves the path for a tenant-specific file, with an option to enforce strict finding.
init()  : self
Initializes the configuration manager with a specific application path.
isInProdEnvironment()  : bool
Determines if the application is running in a production environment.
isPhpFile()  : bool
Determines if a given file is a PHP file by checking its extension and searching for valid PHP opening tags in its content.
isProd()  : bool
Determines if the given environment is a production environment.
json()  : mixed
load()  : void
Load a configuration file by name.
loadArrayFile()  : array<string|int, mixed>
Safely require a file that should return an array.
updateConfigCache()  : void
Add to the configuration cache.
wpdb()  : mixed
appSettingsFileArray()  : array<string|int, mixed>
getConfigsPath()  : mixed
getDefaultWhitelist()  : array<string|int, array<string|int, string>>
loadConfigFile()  : null|DotAccess
Loads and merges a JSON configuration file into the configuration cache.
multiMerge()  : array<string|int, mixed>
Merges two multi-dimensional arrays recursively.
refreshConfig()  : static
setEnvWhitelist()  : array<string|int, mixed>
setMiddlewares()  : array<string|int, mixed>
dbUrl()  : string
Generates a hashed Adminer URL using a specified hashing algorithm.
getDefaultMiddlewares()  : mixed

Properties

$config

Configuration array used by the application.

public mixed $config

Gives us back an array with DotAccess

Configuration settings.

$appPath

The absolute path to the application directory.

protected string $appPath

Path to the application directory.

$configCache

Cache for loaded configurations.

protected array<string|int, mixed> $configCache = []

An array holding cached configuration data.

$configsPath

The absolute path to the application configurations directory.

protected string $configsPath

Path to the configuration directory.

$defaultMiddlewares

Default middlewares applied to the application.

protected static array<string|int, mixed> $defaultMiddlewares

Default middlewares.

$defaultWhitelist

Default whitelist settings for the application.

protected static array<string|int, mixed> $defaultWhitelist

Default whitelist settings.

$frameworkConfigsPath

The absolute path to the framework's configuration files.

protected static string $frameworkConfigsPath

Path to the framework's configuration directory.

Methods

__construct()

Constructor for the configuration manager.

public __construct([array<string|int, mixed> $preloadConfigs = ['tenancy', 'tenants', 'kiosk', 'shortinit'] ][, null|string $appPath = null ]) : mixed

Initializes the application paths, framework configuration paths, and preloads specific configuration files. Also sets default values for the whitelist and middlewares, and caches the configuration.

Parameters
$preloadConfigs : array<string|int, mixed> = ['tenancy', 'tenants', 'kiosk', 'shortinit']

Optional. List of configuration files to preload. Defaults to ['tenancy', 'tenants', 'kiosk'].

$appPath : null|string = null

Optional. Custom application directory path. If not provided, defaults to the APP_DIR_PATH constant.

Return values
mixed

addConfig()

public addConfig(string $file) : void
Parameters
$file : string

The base name of the configuration file (without the .json extension).

Return values
void

app()

Loads the `app` options separately to avoid side effects.

public app() : static

This method initializes the app configuration options and caches it. Afterward, it refreshes the entire configuration.

Return values
static

Returns the current instance of the class after refreshing the configuration.

appOptions()

public appOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

clearConfigCache()

Clear the configuration cache or optionally for a specific key.

public clearConfigCache([string|null $key = null ]) : void
Parameters
$key : string|null = null
Return values
void

dbAdminer()

Load the Adminer script.

public static dbAdminer() : void
Tags
throws
RuntimeException

If the Adminer script cannot be found.

Return values
void

defaultConfigPath()

public static defaultConfigPath() : mixed
Return values
mixed

envTenantId()

public static envTenantId() : string|null
Return values
string|null

get()

public get([string|null $key = null ][, mixed $default = null ]) : mixed
Parameters
$key : string|null = null
$default : mixed = null
Return values
mixed

getActivePlugins()

public getActivePlugins() : mixed
Return values
mixed

getAppPath()

public getAppPath() : mixed
Return values
mixed

getConfig()

Get a loaded configuration by key.

public getConfig(string $key) : DotAccess|null
Parameters
$key : string
Return values
DotAccess|null

getConfigsDir()

public getConfigsDir() : mixed
Return values
mixed

getDefault()

public static getDefault() : array<string|int, null|mixed|(null|bool|mixed|(null|bool|int|mixed|string|string[])[]|string)[]>
Tags
psalm-return

array{error_handler: array{class: ErrorHandler::class, quit: true, logs: true}, dbadmin: array{enabled: true, uri: string, validate: true, autologin: true, secret: array{key: mixed, type: 'jwt'}}, health_status: array{enabled: true, secret: mixed, route: 'up'}, prod: list{'secure', 'sec', 'production', 'prod'}, terminate: array{debugger: false}, twig: array{env_options: array{debug: false, charset: 'utf-8', cache: false, auto_reload: null, strict_variables: false, autoescape: 'html', optimizations: -1}}, directory: array{wp_dir_path: 'wp', web_root_dir: mixed, content_dir: mixed, plugin_dir: mixed, mu_plugin_dir: mixed, sqlite_dir: mixed, sqlite_file: mixed, theme_dir: mixed, asset_dir: mixed, publickey_dir: mixed}, default_theme: mixed, disable_updates: mixed, can_deactivate: mixed, security: array{restrict_wpadmin: array{enabled: false, secure: false, allowed: list{'admin-ajax.php'}}, sucuri_waf: false, encryption_key: null, 'brute-force': true, 'two-factor': true, 'no-pwned-passwords': true, 'admin-ips': array<never, never>}, mailer: array{brevo: array{apikey: mixed}, postmark: array{token: mixed}, sendgrid: array{apikey: mixed}, mailerlite: array{apikey: mixed}, mailgun: array{domain: mixed, secret: mixed, endpoint: mixed, scheme: 'https'}, ses: array{key: mixed, secret: mixed, region: mixed}}, sudo_admin: mixed, sudo_admin_group: null, s3uploads: array{bucket: mixed, key: mixed, secret: mixed, region: mixed, 'bucket-url': mixed, 'object-acl': mixed, expires: mixed, 'http-cache': mixed}, redis: array{disabled: mixed, host: mixed, port: mixed, password: mixed, adminbar: mixed, 'disable-metrics': mixed, 'disable-banners': mixed, prefix: mixed, database: mixed, timeout: mixed, 'read-timeout': mixed}, publickey: array{'app-key': mixed}, headless: array{enabled: false, rest_api: array{enabled: true, cache: false}, graphql: array{enabled: false}, themes: false, plugins: array{load: array<never, never>}, debug: false, error_handling: 'log', security: array{cors: true, allowed_origins: list{'*'}}}, shortinit: array{enabled: false, cache: true, debug: false, components: array{database: true, user: false}, error_handling: 'log', api: array{enabled: false, routes: array<never, never>}}}

Return values
array<string|int, null|mixed|(null|bool|mixed|(null|bool|int|mixed|string|string[])[]|string)[]>

getTenantFilePath()

Retrieves the path for a tenant-specific file, with an option to enforce strict finding.

public getTenantFilePath(string $dir[, bool $find_or_fail = false ]) : null|array<string|int, null|mixed|(null|bool|mixed|(null|false|int|mixed|string)[]|string)[]|string>|string

In a multi-tenant application, this function attempts to find a file specific to the current tenant. If the file is not found and 'find_or_fail' is set to true, the function will return null. If the tenant-specific file does not exist (and 'find_or_fail' is false), it falls back to a default file path. If neither file is found, or the application is not in multi-tenant mode, null is returned.

Parameters
$dir : string

The directory within the app path where the file should be located.

$find_or_fail : bool = false

Whether to fail if the tenant-specific file is not found.

Tags
psalm-return

array{error_handler: array{class: ErrorHandler::class, quit: true, logs: true}, prod: list{'secure', 'sec', 'production', 'prod'}, config_file: 'config', terminate: array{debugger: false}, twig: array{env_options: array{debug: false, charset: 'utf-8', cache: false, auto_reload: null, strict_variables: false, autoescape: 'html', optimizations: -1}}, directory: array{wp_dir_path: 'wp', web_root_dir: mixed, content_dir: mixed, plugin_dir: mixed, mu_plugin_dir: mixed, sqlite_dir: mixed, sqlite_file: mixed, theme_dir: mixed, asset_dir: mixed, publickey_dir: mixed}, default_theme: mixed, disable_updates: mixed, can_deactivate: mixed, security: array{sucuri_waf: false, encryption_key: null, 'brute-force': true, 'two-factor': true, 'no-pwned-passwords': true, 'admin-ips': array<never, never>}, mailer: array{brevo: array{apikey: mixed}, postmark: array{token: mixed}, sendgrid: array{apikey: mixed}, mailerlite: array{apikey: mixed}, mailgun: array{domain: mixed, secret: mixed, endpoint: mixed, scheme: 'https'}, ses: array{key: mixed, secret: mixed, region: mixed}}, sudo_admin: mixed, sudo_admin_group: null, s3uploads: array{bucket: mixed, key: mixed, secret: mixed, region: mixed, 'bucket-url': mixed, 'object-acl': mixed, expires: mixed, 'http-cache': mixed}, redis: array{disabled: mixed, host: mixed, port: mixed, password: mixed, adminbar: mixed, 'disable-metrics': mixed, 'disable-banners': mixed, prefix: mixed, database: mixed, timeout: mixed, 'read-timeout': mixed}, publickey: array{'app-key': mixed}}|null|string

Return values
null|array<string|int, null|mixed|(null|bool|mixed|(null|false|int|mixed|string)[]|string)[]|string>|string

init()

Initializes the configuration manager with a specific application path.

public static init([string $appPath = null ]) : self

Creates a new instance of the class, preloading the default configuration files ('tenancy', 'tenants', 'kiosk') and setting the provided application path.

Parameters
$appPath : string = null

The absolute path to the application directory.

Return values
self

Returns an instance of the class.

isInProdEnvironment()

Determines if the application is running in a production environment.

public static isInProdEnvironment([array<string|int, mixed> $prodEnvironments = ['secure', 'sec', 'production', 'prod'] ]) : bool

This method checks the current environment against a list of production environment identifiers. The list of identifiers can be configured via the prod configuration key or will default to common production identifiers such as 'secure', 'sec', 'production', and 'prod'.

Parameters
$prodEnvironments : array<string|int, mixed> = ['secure', 'sec', 'production', 'prod']
Return values
bool

True if the application is in a production environment, false otherwise.

isPhpFile()

Determines if a given file is a PHP file by checking its extension and searching for valid PHP opening tags in its content.

public static isPhpFile(string $filePath[, int $readBytes = 1024 ]) : bool
Parameters
$filePath : string

The file path or filename.

$readBytes : int = 1024

Maximum number of bytes to read from the start of the file (default: 1024).

Return values
bool

True if the file is recognized as a PHP file, False otherwise.

isProd()

Determines if the given environment is a production environment.

public static isProd(null|string $environment[, array<string|int, mixed> $production = ['secure', 'sec', 'production', 'prod'] ]) : bool

This method checks whether the provided environment string matches one of the predefined production environment names. If the environment is null, it defaults to assuming a production environment for safety, ensuring sensitive data is not accidentally exposed.

Parameters
$environment : null|string

The current environment name. Can be null.

$production : array<string|int, mixed> = ['secure', 'sec', 'production', 'prod']

An array of environment names that are considered production. Defaults to ['secure', 'sec', 'production', 'prod'].

Return values
bool

Returns true if the environment is null or matches one of the production names, otherwise returns false.

json()

public json([string|null $filePath = null ]) : mixed
Parameters
$filePath : string|null = null
Return values
mixed

load()

Load a configuration file by name.

public static load(string $file) : void
Parameters
$file : string

The configuration file name (without extension).

Tags
throws
InvalidArgumentException

If the file does not exist.

Return values
void

loadArrayFile()

Safely require a file that should return an array.

public static loadArrayFile(string $filePath) : array<string|int, mixed>
Parameters
$filePath : string

The path to the PHP file that returns an array.

Tags
throws
RuntimeException

If the file does not exist or is not readable.

throws
UnexpectedValueException

If the file does not return an array.

Return values
array<string|int, mixed>

The array loaded from the file.

updateConfigCache()

Add to the configuration cache.

public updateConfigCache(string $key, DotAccess $item) : void
Parameters
$key : string
$item : DotAccess
Return values
void

wpdb()

public static wpdb([string|null $tableNameNoPrefix = null ]) : mixed
Parameters
$tableNameNoPrefix : string|null = null
Return values
mixed

appSettingsFileArray()

protected appSettingsFileArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

getConfigsPath()

protected getConfigsPath(string $appPath) : mixed
Parameters
$appPath : string
Return values
mixed

getDefaultWhitelist()

protected static getDefaultWhitelist() : array<string|int, array<string|int, string>>
Tags
psalm-return

array{framework: list{'HOME_URL', 'ADMIN_LOGIN_URL', 'KIOSK_DOMAIN_ID', 'ERROR_HANDLER', 'ADMINER_URI', 'ADMINER_SECRET', 'HEALTH_STATUS_SECRET', 'ENVIRONMENT_TYPE', 'WEB_ROOT_DIR', 'CONTENT_DIR', 'PLUGIN_DIR', 'MU_PLUGIN_DIR', 'SQLITE_DIR', 'SQLITE_FILE', 'THEME_DIR', 'ASSET_DIR', 'PUBLICKEY_DIR', 'DEFAULT_THEME', 'DISABLE_UPDATES', 'CAN_DEACTIVATE', 'APP_ASSETS_DIR', 'APP_CONTENT_DIR', 'APP_HTTP_HOST', 'APP_PATH', 'APP_TENANT_ID', 'APP_TENANT_SECRET', 'ASSET_URL', 'DEVELOPER_ADMIN', 'AVADAKEY', 'AWS_ACCESS_KEY_ID', 'AWS_DEFAULT_REGION', 'AWS_SECRET_ACCESS_KEY', 'BACKUP_PLUGINS', 'BASIC_AUTH_PASSWORD', 'BASIC_AUTH_USER', 'BREVO_API_KEY', 'CAN_DEACTIVATE_PLUGINS', 'DB_DIR', 'DB_FILE', 'DELETE_LOCAL_S3BACKUP', 'DISABLE_WP_APPLICATION_PASSWORDS', 'ELEMENTOR_AUTO_ACTIVATION', 'ELEMENTOR_PRO_LICENSE', 'ENABLE_S3_BACKUP', 'ENABLE_SUCURI_WAF', 'IS_MULTI_TENANT_APP', 'IS_MULTITENANT', 'LANDLORD_DB_HOST', 'LANDLORD_DB_NAME', 'LANDLORD_DB_USER', 'LANDLORD_DB_PASSWORD', 'LANDLORD_DB_PREFIX', 'MAILERLITE_API_KEY', 'MAILGUN_DOMAIN', 'MAILGUN_ENDPOINT', 'MAILGUN_SECRET', 'MAX_MEMORY_LIMIT', 'MEMORY_LIMIT', 'POSTMARK_TOKEN', 'PUBLIC_WEB_DIR', 'S3_BACKUP_BUCKET', 'S3_BACKUP_DIR', 'S3_BACKUP_KEY', 'S3_BACKUP_REGION', 'S3_BACKUP_SECRET', 'S3ENCRYPTED_BACKUP', 'S3_UPLOADS_BUCKET', 'S3_UPLOADS_BUCKET_URL', 'S3_UPLOADS_HTTP_CACHE_CONTROL', 'S3_UPLOADS_HTTP_EXPIRES', 'S3_UPLOADS_KEY', 'S3_UPLOADS_OBJECT_ACL', 'S3_UPLOADS_REGION', 'S3_UPLOADS_SECRET', 'SENDGRID_API_KEY', 'SEND_EMAIL_CHANGE_EMAIL', 'SUDO_ADMIN', 'SUDO_ADMIN_GROUP', 'TEST_COOKIE', 'USE_APP_THEME', 'WEB_APP_PUBLIC_KEY', 'WP_DIR_PATH', 'WPENV_AUTO_LOGIN_SECRET_KEY', 'WP_REDIS_DATABASE', 'WP_REDIS_DISABLE_ADMINBAR', 'WP_REDIS_DISABLE_BANNERS', 'WP_REDIS_DISABLE_METRICS', 'WP_REDIS_HOST', 'WP_REDIS_PASSWORD', 'WP_REDIS_PORT', 'WP_REDIS_PREFIX', 'WP_REDIS_TIMEOUT', 'WP_REDIS_READ_TIMEOUT', 'WP_REDIS_DISABLED', 'WP_SUDO_ADMIN', 'USE_STRICT_ENV_VARS'}, wp: list{'WP_DEVELOPMENT_MODE', 'WP_MEMORY_LIMIT', 'WP_MAX_MEMORY_LIMIT', 'WP_ALLOW_REPAIR', 'DO_NOT_UPGRADE_GLOBAL_TABLES', 'DB_HOST', 'DB_NAME', 'DB_PASSWORD', 'DB_PREFIX', 'DB_ROOT_PASS', 'DB_USER', 'DB_CHARSET', 'DB_COLLATE', 'WP_SITEURL', 'WP_DEFAULT_THEME', 'RELOCATE', 'FS_METHOD', 'FS_CHMOD_DIR', 'FS_CHMOD_FILE', 'WP_TEMP_DIR', 'WP_CONTENT_URL', 'WP_CONTENT_DIR', 'WP_PLUGIN_DIR', 'WP_PLUGIN_URL', 'PLUGINDIR', 'WPMU_PLUGIN_DIR', 'WPMU_PLUGIN_URL', 'MUPLUGINDIR', 'TEMPLATEPATH', 'STYLESHEETPATH', 'WP_POST_REVISIONS', 'AUTOSAVE_INTERVAL', 'COOKIE_DOMAIN', 'COOKIEHASH', 'COOKIEPATH', 'SITECOOKIEPATH', 'ADMIN_COOKIE_PATH', 'PLUGINS_COOKIE_PATH', 'USER_COOKIE', 'PASS_COOKIE', 'AUTH_COOKIE', 'SECURE_AUTH_COOKIE', 'LOGGED_IN_COOKIE', 'RECOVERY_MODE_COOKIE', 'WP_DEBUG', 'WP_DEBUG_LOG', 'WP_DEBUG_DISPLAY', 'WP_LOCAL_DEV', 'CONCATENATE_SCRIPTS', 'SCRIPT_DEBUG', 'SAVEQUERIES', 'COMPRESS_SCRIPTS', 'COMPRESS_CSS', 'ENFORCE_GZIP', 'DISABLE_WP_CRON', 'ALTERNATE_WP_CRON', 'WP_CRON_LOCK_TIMEOUT', 'FORCE_SSL_LOGIN', 'FORCE_SSL_ADMIN', 'WP_HTTP_BLOCK_EXTERNAL', 'WP_ACCESSIBLE_HOSTS', 'DISALLOW_FILE_EDIT', 'DISALLOW_FILE_MODS', 'IMAGE_EDIT_OVERWRITE', 'AUTOMATIC_UPDATER_DISABLED', 'WP_AUTO_UPDATE_CORE', 'WPLANG', 'WP_LANG_DIR', 'EMPTY_TRASH_DAYS', 'MEDIA_TRASH', 'SHORTINIT', 'WP_USE_THEMES', 'WP_SANDBOX_SCRAPING', 'WP_START_TIMESTAMP', 'RECOVERY_MODE_EMAIL', 'AUTH_KEY', 'AUTH_SALT', 'LOGGED_IN_KEY', 'LOGGED_IN_SALT', 'NONCE_KEY', 'NONCE_SALT', 'SECURE_AUTH_KEY', 'SECURE_AUTH_SALT'}}

Return values
array<string|int, array<string|int, string>>

loadConfigFile()

Loads and merges a JSON configuration file into the configuration cache.

protected loadConfigFile(string $file[, null|string $defaultPath = null ]) : null|DotAccess

This method attempts to load a configuration file from multiple sources, merges configuration data from user-defined and default paths, and caches the result for future use. Special handling is provided for composer.json, which is directly processed if it exists.

Parameters
$file : string

The base name of the configuration file (without the .json extension).

$defaultPath : null|string = null

Optional. A fallback path to look for the configuration file if it is not found in the user-defined configuration path. Defaults to the result of self::defaultConfigPath().

Tags
throws
RuntimeException

If the configuration file does not exist in any of the expected locations.

Return values
null|DotAccess

Returns an instance of DotAccess containing the merged configuration data, or null if the configuration file does not exist.

multiMerge()

Merges two multi-dimensional arrays recursively.

protected static multiMerge(array<string|int, mixed> $array1, array<string|int, mixed> $array2) : array<string|int, mixed>

This function will recursively merge the values of $array2 into $array1. If the same key exists in both arrays, and both corresponding values are arrays, the values are recursively merged. Otherwise, values from $array2 will overwrite those in $array1.

Parameters
$array1 : array<string|int, mixed>

The base array that will be merged into.

$array2 : array<string|int, mixed>

The array with values to merge into $array1.

Return values
array<string|int, mixed>

The merged array.

refreshConfig()

protected refreshConfig() : static
Return values
static

setEnvWhitelist()

protected setEnvWhitelist(array<string|int, mixed> $defaultWhitelist) : array<string|int, mixed>
Parameters
$defaultWhitelist : array<string|int, mixed>
Return values
array<string|int, mixed>

setMiddlewares()

protected setMiddlewares(array<string|int, mixed> $defaultMiddlewares) : array<string|int, mixed>
Parameters
$defaultMiddlewares : array<string|int, mixed>
Return values
array<string|int, mixed>

dbUrl()

Generates a hashed Adminer URL using a specified hashing algorithm.

private static dbUrl(string $hashAlgo) : string
Parameters
$hashAlgo : string

The hashing algorithm to use (e.g., 'fnv1a64', 'sha256', 'md5').

Return values
string

The hashed database URL.

getDefaultMiddlewares()

private static getDefaultMiddlewares() : mixed
Return values
mixed

Search results