Documentation

AppConf
in package

Read onlyYes
FinalYes

Creates and validates a configuration given the path to the project folder.

It creates a configuration file that merges the distributed configuration file, lmwf_app.json, with the local file, .lmwf_app.local.json. If the two define the same key, the latter overrides the former. Note that the entire value for the key is overriden, even if the value is a dictionnary.

Tags
todo

Add appName setting.

Table of Contents

Constants

APP_PATH_KEY  : string = "appPath"
DIST_FN  : string = "lmwf_app.json"
HANLDE_EXCEPTIONS  : string = "handleExceptions"
LANGUAGE_KEY  : string = "language"
LOCAL_FN  : string = ".lmwf_app.local.json"

Properties

$appRootPath  : string
$baseUrl  : string
$data  : AppObject<string|int, mixed>
Gives access to the raw configuration data.
$handleExceptions  : bool
$httpConf  : HttpConf
$isDev  : bool
$language  : string
$publicRelPath  : string
$thumbnailFormats  : array<string, ImgFormat>
$uploadRelPath  : string

Methods

__construct()  : mixed
The path is the absolute path on the server file system. The relative path is the path on the file system relative to the app root.
createFromEnvFile()  : self
The dist file must exists. The local file might not exist, but if it exists it must be readable and valid.
getBoolSetting()  : bool
getNullableSetting()  : string|null
getPathOfUploadedFiles()  : string
getSetting()  : string
hasSetting()  : bool
readCsps()  : array<string, array<int, string>>
readErrorControllerFqcn()  : IController>

Constants

APP_PATH_KEY

public string APP_PATH_KEY = "appPath"

DIST_FN

public string DIST_FN = "lmwf_app.json"

HANLDE_EXCEPTIONS

public string HANLDE_EXCEPTIONS = "handleExceptions"

LANGUAGE_KEY

public string LANGUAGE_KEY = "language"

LOCAL_FN

public string LOCAL_FN = ".lmwf_app.local.json"

Properties

$appRootPath

public string $appRootPath

$data

Gives access to the raw configuration data.

public AppObject<string|int, mixed> $data

Stored as AppObject to ensure it cannot be mutated.

$handleExceptions

public bool $handleExceptions

$publicRelPath

public string $publicRelPath

$uploadRelPath

public string $uploadRelPath

Methods

__construct()

The path is the absolute path on the server file system. The relative path is the path on the file system relative to the app root.

public __construct(AppObject<string|int, mixed> $confParams) : mixed
Parameters
$confParams : AppObject<string|int, mixed>
Tags
todo

Create model for configuration, and check it is valid? (Would make testing harder.)

Accept an array and create a model from it?

createFromEnvFile()

The dist file must exists. The local file might not exist, but if it exists it must be readable and valid.

public static createFromEnvFile(string $confFolderPath[, array<string, mixed> $confData = [] ]) : self
Parameters
$confFolderPath : string
$confData : array<string, mixed> = []
Tags
todo

Add JSON_THROW_ON_ERROR everywhere, and automatically check its presence.

Rename to "createFromFolderPath" or something like it.

Return values
self

getBoolSetting()

public getBoolSetting(string $key) : bool
Parameters
$key : string
Return values
bool

getNullableSetting()

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

getPathOfUploadedFiles()

public getPathOfUploadedFiles() : string
Return values
string

getSetting()

public getSetting(array<string|int, mixed>|string $key) : string
Parameters
$key : array<string|int, mixed>|string
Return values
string

hasSetting()

public hasSetting(string $key) : bool
Parameters
$key : string
Return values
bool

readCsps()

private readCsps(AppObject<string|int, mixed> $confParams) : array<string, array<int, string>>
Parameters
$confParams : AppObject<string|int, mixed>
Return values
array<string, array<int, string>>

readErrorControllerFqcn()

private readErrorControllerFqcn(AppObject<string|int, mixed> $confParams, string $error) : IController>
Parameters
$confParams : AppObject<string|int, mixed>
$error : string
Return values
IController>
On this page

Search results