'', // IP address of the database server e.g. 127.0.0.1 'user' => '', // Username of the database server e.g. root 'password' => '', // Password of the database server e.g. password123 'database' => '', // Name of the database e.g. my_database 'port' => 3306, // Port of the database server e.g. 3306 'ssl_mode' => 'DISABLED' // SSL mode for mysqldump: DISABLED, PREFERRED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY ]; $DEBUG = true; // Set to true to enable debugging (Error messages will be shown, and this should never be used in production) $USE_PROD_ECONOMIC_IN_DEBUG = true; // Set to true to use the production economic API in debug mode $ENCRYPTION_KEY = ''; // 44 Characters long encryption key $CORS = '*'; // Set to comma-separated allowed origins e.g. https://example.com,https://api-v2.truckwash.io $ECONOMIC_API = [ 'app_access_grant' => '', // Economic API access grant token (1) 'app_access_grant2' => '', // Economic API access grant token (2) 'app_secret_token' => '' // Economic API secret token ]; if ($DEBUG && !$USE_PROD_ECONOMIC_IN_DEBUG) { $ECONOMIC_API = [ 'app_access_grant' => '', // Development Economic API access grant token (1) 'app_access_grant2' => '', // Development Economic API access grant token (2) 'app_secret_token' => '' // Development Economic API secret token ]; } $WORDPRESS_STATIC_TOKEN = ''; // Static token used to authenticate the WordPress plugin $EMAIL_WASH_CERTIFICATE_TOKEN = ''; // Token used to authenticate the wash certificate generator $WORDPRESS_API_URL = ''; // URL to the WordPress API ajax endpoint e.g. https://example.com/wp-admin/admin-ajax.php $MINIO = [ 'endpoint' => '', // Minio endpoint e.g. http://0.0.0.0:9000 'access_key' => '', // Minio access 'secret_key' => '' // Minio secret key ]; $SLACK_DEFAULT_WEBHOOK = ''; // Default Slack webhook URL e.g. https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX $REDIS_CONFIG = [ 'host' => '', // Redis host (IP address) 'user' => '', // Redis user 'database' => 0, // Redis database number (0-15) 'password' => '', // Redis password 'port' => 6379 // Redis port ]; // Set the timezone date_default_timezone_set('Europe/Copenhagen'); /** * Check if the environment variables are set (If we are running in a Docker container) */ if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') { // Set the configuration from the environment variables $ENV_VARIABLES = [ 'CONFIG_DB_HOST' => 'host', 'CONFIG_DB_USER' => 'user', 'CONFIG_DB_PASSWORD' => 'password', 'CONFIG_DB_DATABASE' => 'database', 'CONFIG_DB_PORT' => 'port', 'CONFIG_DB_SSL_MODE' => 'ssl_mode', 'DEBUG' => 'DEBUG', 'ENCRYPTION_KEY' => 'ENCRYPTION_KEY', 'CORS' => 'CORS', 'ECONOMIC_API_APP_ACCESS_GRANT' => 'app_access_grant', 'ECONOMIC_API_APP_ACCESS_GRANT2' => 'app_access_grant2', 'ECONOMIC_API_APP_SECRET_TOKEN' => 'app_secret_token', 'WORDPRESS_STATIC_TOKEN' => 'WORDPRESS_STATIC_TOKEN', 'EMAIL_WASH_CERTIFICATE_TOKEN' => 'EMAIL_WASH_CERTIFICATE_TOKEN', 'WORDPRESS_API_URL' => 'WORDPRESS_API_URL', 'MINIO_ENDPOINT' => 'endpoint', 'MINIO_ACCESS_KEY' => 'access_key', 'MINIO_SECRET_KEY' => 'secret_key', 'SLACK_DEFAULT_WEBHOOK' => 'SLACK_DEFAULT_WEBHOOK', 'REDIS_CONFIG_HOST' => 'host', 'REDIS_CONFIG_DATABASE' => 'database', 'REDIS_CONFIG_PASSWORD' => 'password', 'REDIS_CONFIG_PORT' => 'port', 'REDIS_CONFIG_USER' => 'user', 'REDIS_CONFIG_DEBUG_PASSWORD' => 'debug_password' ]; $dbTarget = strtolower(trim((string)($_ENV['CONFIG_DB_TARGET'] ?? 'live'))); if ($dbTarget !== 'live' && $dbTarget !== 'debug') { $dbTarget = 'live'; } $resolveDbValue = function (string $key) use ($dbTarget): string { $liveKey = 'CONFIG_DB_' . $key; $debugKey = 'CONFIG_DB_DEBUG_' . $key; $liveValue = (string)($_ENV[$liveKey] ?? ''); $debugValue = (string)($_ENV[$debugKey] ?? ''); if ($dbTarget === 'debug' && $debugValue !== '') { return $debugValue; } return $liveValue; }; /** * Set the db configuration from selected target (live/debug) */ $CONFIG_DB = [ 'host' => $resolveDbValue('HOST'), 'user' => $resolveDbValue('USER'), 'password' => $resolveDbValue('PASSWORD'), 'database' => $resolveDbValue('DATABASE'), 'port' => (int)($resolveDbValue('PORT') ?: 3306), 'ssl_mode' => $resolveDbValue('SSL_MODE') !== '' ? $resolveDbValue('SSL_MODE') : 'DISABLED' ]; /** * Set the debug configuration */ $DEBUG = $_ENV['DEBUG']; /** * Set the encryption key */ $ENCRYPTION_KEY = $_ENV['ENCRYPTION_KEY']; /** * Set the CORS configuration */ $CORS = $_ENV['CORS']; /** * Set the economic API configuration */ $ECONOMIC_API = [ 'app_access_grant' => $_ENV['ECONOMIC_API_APP_ACCESS_GRANT'], 'app_access_grant2' => $_ENV['ECONOMIC_API_APP_ACCESS_GRANT2'], 'app_secret_token' => $_ENV['ECONOMIC_API_APP_SECRET_TOKEN'] ]; /** * Set the WordPress static token */ $WORDPRESS_STATIC_TOKEN = $_ENV['WORDPRESS_STATIC_TOKEN']; /** * Set the email wash certificate token */ $EMAIL_WASH_CERTIFICATE_TOKEN = $_ENV['EMAIL_WASH_CERTIFICATE_TOKEN']; /** * Set the WordPress API URL */ $WORDPRESS_API_URL = $_ENV['WORDPRESS_API_URL']; /** * Set the Minio configuration */ $MINIO = [ 'endpoint' => $_ENV['MINIO_ENDPOINT'], 'access_key' => $_ENV['MINIO_ACCESS_KEY'], 'secret_key' => $_ENV['MINIO_SECRET_KEY'] ]; /** * Set the Slack default webhook */ $SLACK_DEFAULT_WEBHOOK = $_ENV['SLACK_DEFAULT_WEBHOOK']; $resolveRedisValue = function (string $key) use ($dbTarget): string { $liveKey = 'REDIS_CONFIG_' . $key; $debugKey = 'REDIS_CONFIG_DEBUG_' . $key; $liveValue = (string)($_ENV[$liveKey] ?? ''); $debugValue = (string)($_ENV[$debugKey] ?? ''); if ($dbTarget === 'debug' && $debugValue !== '') { return $debugValue; } return $liveValue; }; /** * Set the Redis configuration */ $REDIS_CONFIG = [ 'host' => $resolveRedisValue('HOST'), 'user' => $resolveRedisValue('USER'), 'database' => $resolveRedisValue('DATABASE'), 'password' => $resolveRedisValue('PASSWORD'), 'port' => (int)($resolveRedisValue('PORT') ?: 6379) ]; // Set the timezone date_default_timezone_set($_ENV['CONFIG_TIMEZONE']) ?? 'Europe/Copenhagen'; }