Configuration Structure
Most, though not all, of Deserted Chateau's configuration items that are relevant to the webservers are held in three database tables:
configuration
This is the main configuration table. This table holds configuration items for a variety of different "modules", each of which represents a specific group of configuration items, such as WebConfig or AwsS3Config.
configuration_head_scripts
This table holds a list of scripts and stylesheets to be added to all pages, the order in which they are to be loaded, version numbers for each script or stylesheet and other information.
configuration_extra_scripts
This table is similar to configuration_head_scripts, but holds information on scripts that are only used on some pages and are loaded by pages as needed.
PHP Classes
The values held in the configuration table are loaded by webservers via the Config/Config.php class, which acts as a primary class to load and retrieve name/value pairs from specific configuration "modules". The usual call structure is below:
// Retrieve the WebConfig::VALID_USERNAME_REGEX value from the
// configuration table in the database.
//
// In practice, this will usually be retrieved from a cached copy
// of the configuration table in Redis.
$configValue = Config::get(WebConfig::VALID_USERNAME_REGEX);
Each configuration "module" class specifies a list of public constants that act as keys. In the below example, the WebConfig::VALID_USERNAME_REGEX constant resolves to a string value that represents the configuration table entry with module "WebConfig" and name "valid_username_regex".
<?php
namespace Antsstyle\DesertedChateau\Config;
class WebConfig {
// Specifies the regex used to validate usernames in the account creation form.
public const VALID_USERNAME_REGEX = 'WebConfig::valid_username_regex';
}
Redis caching
If a value from any of these configuration tables is requested by a webserver, and there is no cached copy available in Redis, the webserver retrieves the table contents from the database and adds a cached copy to Redis. This copy has no expiry time, and must be expired manually to force the webserver to retrieve the latest version if changes are made.