Skip to main content

Configuration

OpenDXP's configuration can be found in several places:

  • Configurations in var/config/*.(php|yaml) are written from the admin interface. For example the system.yaml file contains the settings from System Settings
  • The Symfony configuration tree (mainly distributed throughout *.yaml files) contains all Symfony as well as most of the OpenDXP related configurations.
  • A set of OPENDXP_* constants which are used to resolve various filesystem paths

Symfony Configuration

Many aspects of OpenDXP can be configured through the Symfony Config tree defined under the opendxp and opendxp_admin extension. These values can be changed through config files in config (e.g. config/config.yaml)).

OpenDXP additionally includes a set of standard configuration files which, in contrast to a standard Symfony project, are not located in config/, but in the OpenDxpCoreBundle. This allows us to ship and update default configurations without affecting project code in config/. See Auto loading config and routing definitions for details how this works.

Standard configs will be merged with your custom config in config/ to build the final config tree. You can debug the values stored in the tree through the following command:

# this is a core Symfony command and works for every bundle, just omit the
# "opendxp" argument to get a list of all bundles
$ bin/console debug:config opendxp

In addition, you can print a reference of valid configuration sections with the following command:

$ bin/console config:dump-reference opendxp

OpenDXP constants

OpenDXP uses several constants for locating certain directories like logging, assets, versions etc. These constants are defined in lib/Bootstrap.php.

If you need to overwrite these constants (e.g. for using a special directory for assets or versions at an object storage at AWS S3), you have multiple ways to do so:

  • Create a file in /config/opendxp/constants.php setting the constants you need. OpenDXP will skip setting any constants which are already defined.
  • Define an environment variable named after the constant. When defining a constant, OpenDXP will look if an env variable with the same name is defined and use that instead of the default value.
  • Define an environment variable in a /.env file which will be automatically loaded through the Symfony DotEnv component if it exists. Environment variables defined here will have the same effect as "real" environment variables. See the Environment-Specific Configurations section for more details.

The OpenDXP Skeleton repository contains an example file, constants.example.php. The following file is an example of how you can overwrite some paths:

<?php

// to use this file you have to rename it to constants.php
// you can use this file to overwrite the constants defined in lib/Bootstrap.php

define("OPENDXP_CLASS_DIRECTORY", "/my/tmp/path");

Please see lib/Bootstrap.php for a list of defined constants.

The OPENDXP_PROJECT_ROOT constant

There is one special constant OPENDXP_PROJECT_ROOT which is used to resolve the root directory (see Directory Structure) of the application. In contrast to the remaining constants, this constant is not defined in constants.php as it is already needed to resolve the path to the constants.php file. It is defined in OpenDXP's bootstrapping class \OpenDxp\Bootstrap::setProjectRoot() instead.

You can change the project root through an env variable (or by defining a constant before loading the entry point) if needed and OpenDXP will fall back to its standard value if not defined. If you use OpenDxp's standard directory layout as shipped in the zip file, you don't have to set anything, but if you need some kind of special setup you have full control over the used paths here.

In contrast to the other constants, OPENDXP_PROJECT_ROOT can not be set via .env OpenDXP doesn't know where to look for a .env file at this point.

Adding logic to the startup process

If you need to execute code to influence OpenDXP's startup process, you can do so by adding a file in /config/opendxp/startup.php which will be automatically included as part of the bootstrap process. Specifically, it will be loaded after all other bootstrapping (loading the autoloader, parsing constants, ...) is done, but before the kernel is loaded and booted. This gives you the possibility to reconfigure environment settings before they are used and to configure the system for your needs. Examples:

<?php

// /config/opendxp/startup.php

use \Symfony\Component\HttpFoundation\Request;

Request::setTrustedProxies(['192.0.0.1', '10.0.0.0/8'], Request::HEADER_X_FORWARDED_ALL);