Skip to main content
page last edited on 18 July 2022

Configuration

Version: 5.6.0

Configuration is a set of data whose values affect the operation of X-Cart.

Static configuration is data written to a file. It is assumed that this data does not change during X-Cart operation; if it changes, Symfony cache needs to be regenerated.

Dynamic configuration is data written to a database. The values can change dynamically; in some cases, X-Cart cache needs to be regenerated.

Runtime configuration is data that is calculated on each request and is mixed into the static or the dynamic configuration.

Static Configuration

For the purpose of declaring a configuration within Symfony, the X-Cart core is represented as a bundle. Further, the standard functionality is used: https://symfony.com/doc/current/bundles/configuration.html

The configuration scheme is declared in the class \XCart\DependencyInjection\Configuration

Although all the default values are declared in the scheme, the configuration file is still required both from the technical viewpoint and for clarity: src/config/packages/x_cart.yaml

To ensure the correct order, the module files /modules/[Author]/[Name]/config/service.yaml are loaded automatically. A DI extension in a module now only needs to be created if necessary.

The src/config/local/*.yaml files are the last to load.

To extend a configuration with a module or to declare a local configuration, the general scheme of the src/config/packages/x_cart.yaml file must be followed. In this case, declaring values into list variables will lead to automatic merging, whereas declaring them into scalar ones will lead to redefinition.

It is recommended that modules' own variables should be declared in the modules section. Please keep in mind that there will be no merging in the modules section, only redefinition.

There are two ways of changing the configuration from the code:

  • Via CompilerPass. In this case, the changes will be cached. Also, there will be no access to the values set through ENV.
  • In runtime - for example, via the xcart.boot event handler.

In both cases, you need to work with the service \XCart\Domain\StaticConfigDomain.

You can get the configuration values in the code via the \XCart\Domain\StaticConfigDomain service (Symfony way) or via \Includes\Utils\ConfigParser::getOptions (X-Cart way).

Configuring Redis

In X-Cart, Redis is used for storing sessions, locks (for synchronizing certain processes), and cache.

Important: You will require two separate Redis servers — one for sessions and locks, and another for cache.

For sessions and locks, the following env variables are used:

REDIS_HOST
REDIS_PORT
REDIS_DSN

The server must be configured so that entries are not deleted. For example:

maxmemory-policy noeviction
appendonly yes

For cache, the following env variables are used:

REDIS_EXTRA_HOST
REDIS_EXTRA_PORT
REDIS_EXTRA_DSN

Example redis configuration:

maxmemory-policy volatile-lru
appendonly no
save ""