Configuratie & environment¶
De configuratie van de Atraxion-webshop bestaat uit drie lagen: PHP-constanten (omgevingsspecifieke waarden en paden), de setting-tabel (applicatiebrede instellingen beheerbaar via de backoffice), en omgevingsdetectie via de ENVIRONMENT-constante.
Omgevingsbestand: environment_constants.php¶
Het primaire configuratiebestand is _www/appconfig/environment_constants.php. Dit bestand staat niet in versiebeheer en wordt aangemaakt door een kopie te maken van de distributieversie:
# INSTALL.md:9–10
cd _www/appconfig && cp environment_constants.php.dist environment_constants.php
environment_constants.php.dist bevat de volledige lijst van in te vullen constanten met lege of standaardwaarden. Dit bestand wél in versiebeheer, zodat nieuw opgezette omgevingen weten welke waarden nodig zijn.
Inhoud van environment_constants.php¶
De constanten worden geladen door constants.php:15 via:
require __DIR__ . '/environment_constants.php';
Overzicht van de configuratiegroepen (zie _www/appconfig/environment_constants.php.dist):
| Groep | Constanten | Doel |
|---|---|---|
| Omgeving | ENVIRONMENT, APP_DEBUG |
Bepaalt dev/test/beta/prod; debug-modus |
| Database | APP_DB_HOST, DB_USER_NAME, DB_USER_PASSWORD, DB_ADMIN_NAME, DB_ADMIN_PASSWORD, DB_SERVER_VERSION, DB_DRIVER |
MySQL-verbinding |
MAIL_SELF |
Afzenderadres voor systeemmails | |
| Memcached | MEMCACHED_DSN |
Adres van de Memcached-server |
| Odoo ERP | ODOO_API_URI, ODOO_API_DATABASE, ODOO_API_USERNAME, ODOO_API_PASSWORD, ODOO_MIDDLEWARE_* |
Odoo-verbinding en middleware |
| Cloudflare | CLOUDFLARE_API_USER, CLOUDFLARE_API_KEY, CLOUDFLARE_ATRAXION_COM_ZONE_ID |
DNS/cache-beheer |
| Matomo | MATOMO_SITE_ID, MATOMO_SITE_URL, MATOMO_TOKEN_AUTH |
Analytics |
| Arteel | ARTEEL_API_BASE_URL, ARTEEL_API_CLIENT_ID, ARTEEL_API_CLIENT_SECRET, ARTEEL_PORTAL_BASE_URL, ARTEEL_JWT_SIGNING_KEY |
Loyaliteitsprogramma |
| Amazon | AMAZON_CLIENT_ID, AMAZON_CLIENT_SECRET, AMAZON_REFRESH_TOKEN, AMAZON_* |
Amazon SP-API |
| Sentry | SENTRY_DSN |
Foutrapportage |
constants.php: paden en afgeleide constanten¶
_www/appconfig/constants.php wordt altijd ingeladen na het omgevingsbestand. Het definieert:
-
Omgevingslabels (regels 10–13):
const ENVIRONMENT_DEV = 'dev'; const ENVIRONMENT_TEST = 'test'; const ENVIRONMENT_PROD = 'production'; const ENVIRONMENT_STAG = 'beta'; -
Paden (regels 21–35):
APP_PATH,APP_CORE_PATH,APP_ADMIN_PATH,APP_CACHE_PATH,APP_PROJECT_DIR, … -
Hostname-detectie en
APP_CHANNEL(regels 39–57): het actieve channel wordt bepaald op basis van$_SERVER['HTTP_HOST']via een drieweg-conditie:// constants.php:51–57 if (is_prod()) { // manage.atraxion.com wijst altijd naar het default channel define('APP_CHANNEL', APP_SITE_HOST === 'manage.atraxion.com' ? 'www.atraxion.com' : APP_SITE_HOST); } elseif ((is_env(ENVIRONMENT_STAG) || is_env(ENVIRONMENT_DEV)) && !checkManage()) { // staging/dev storefront: host is het channel define('APP_CHANNEL', APP_SITE_HOST); } else { // staging/dev backoffice (manage.*): fallback naar default channel define('APP_CHANNEL', 'www.atraxion.com'); } -
Database-constanten (regels 71–76):
const APP_DB_WWW = 'atx_www'; const APP_DB_LOG = 'atx_log'; const APP_DB_QUEUE = 'atx_queue'; const APP_DB_DWH = 'atx_dwh'; const DB_CHARSET = 'utf8mb4'; -
Databasegebruiker: afhankelijk van
checkManage()worden aparteDB_USER/DB_PASSWORD-constanten ingesteld (constants.php:78–84). De backoffice (manage.*) gebruikt een admin-gebruiker; de storefront een beperkte gebruiker.
Omgevingsdetectie: ENVIRONMENT en helperfuncties¶
De ENVIRONMENT-constante wordt gezet in environment_constants.php (bijv. define('ENVIRONMENT', ENVIRONMENT_PROD)).
Drie helperfuncties bieden een leesbare interface (src/functions.php:408–431):
function is_env($env): bool { return ENVIRONMENT === $env; }
function is_prod(): bool { return is_env(ENVIRONMENT_PROD); }
function is_dev(): bool { return is_env(ENVIRONMENT_DEV); }
Gebruik in de codebase:
is_prod()bepaalt de Twig-debugmodus (TwigServiceProvider.php:30), de cacheaanpak voor Doctrine (DoctrineService.php:103), de versie-hash voor assets (src/functions.php:649), en of Sentry actief is.is_dev()activeert aanvullende loggers en schakelt Doctrine-metadata-caching uit.
Omgevingen¶
| Waarde | Constante | Gebruik |
|---|---|---|
'production' |
ENVIRONMENT_PROD |
Productieserver (www.atraxion.com) |
'beta' |
ENVIRONMENT_STAG |
Stagingserver |
'dev' |
ENVIRONMENT_DEV |
Lokale ontwikkelomgeving |
'test' |
ENVIRONMENT_TEST |
Testomgeving |
_core/config/config.php: bootstrap van de MVC-kern¶
_www/appconfig/config.php laadt eerst bootstrap.php en daarna _core/config/config.php:
// _core/config/config.php (volledige inhoud):
set_error_handler('errorHandler', error_reporting());
// ... inlog-check + sessie-initialisatie ...
require APP_CORE_PATH . '/router.php';
Dit is de kern van de MVC-bootstrap voor de storefront: logincheck, sessievalidatie, en routing.
De setting-tabel¶
Applicatiebrede, dynamische instellingen worden opgeslagen in de tabel atx_www.setting. Elke instelling heeft:
| Kolom | Betekenis |
|---|---|
Type |
Namespace (bijv. atx, atx\articles\acc, atx\channels) |
Name |
Instellingsnaam |
Value |
Waarde (string of JSON) |
ValueType |
Datatype (string, integer, boolean, json) |
Array |
Of de waarde een JSON-array is |
Description |
Beschrijving voor de backoffice |
ReadOnly |
Of de instelling via de backoffice bewerkbaar is |
Toegang vanuit PHP¶
De helper config() in src/functions.php:944 haalt een instelling op via de SettingService:
// src/functions.php:944–951
function config(string $key, object|string|null $namespace = null, mixed $default = null): mixed
{
return ServiceRegistry::getSettings()->getSetting($key, $namespace, $default);
}
Controllerklassen gebruiken ook direct $this->getSetting($name, $namespace) (_core/controller/classes/atx/Controller.php:1183).
Caching van instellingen¶
SettingDAO::getSettings() slaat het volledige resultaat op in de cache onder de sleutel allSettings via cache_get() (_core/model/dbclasses/atx/system/SettingDAO.php:63). Na een wijziging in de setting-tabel is een cache-warmup vereist. Zie Caching.
Voorbeelden van instellingen (uit _data/setting.sql)¶
Instellingen zijn georganiseerd per namespace:
| Namespace | Voorbeeldsleutels |
|---|---|
atx |
red_devils |
atx\articles\acc |
image-default, image-folder, max-shown-articles-stock |
atx\channels |
Channelspecifieke instellingen |
Docker-omgeving¶
Voor de lokale ontwikkelomgeving bestaat docker/environment_constants.docker.php met Docker-specifieke waarden:
// docker/environment_constants.docker.php:53
const MEMCACHED_DSN = 'memcached://memcached:11211'; // docker-compose service name
Dit bestand wordt door de Docker-setup automatisch als environment_constants.php geplaatst. Zie Lokale ontwikkelomgeving voor details.
Samenvatting: configuratievolgorde¶
graph LR
EC[environment_constants.php] --> CO[constants.php]
CO --> BS[bootstrap.php]
BS --> CF[_core/config/config.php]
CF --> SVC[ServiceRegistry / services]
SVC --> STG["setting-tabel (via cache)"]
environment_constants.php— omgevingsspecifieke constanten (niet in git)constants.php— paden, omgevingslabels,APP_CHANNEL, DB-constantenbootstrap.php— vendor-autoload, Sentry, sessie_core/config/config.php— MVC-bootstrap, routingsetting-tabel — dynamische applicatie-instellingen (gecached)