Configuration is an important aspect of versatile applications. Flow provides you with
configuration mechanisms which have a small footprint and are convenient to use and
powerful at the same time. Hub for all configuration is the configuration manager which
handles alls configuration tasks like reading configuration, configuration cascading, and
(later) also writing configuration.

There are several locations where configuration files may be placed. All of them are
scanned by the configuration manager during initialization and cascaded into a single
configuration tree. The following locations exist (listed in the order they are loaded,
i.e. later values override prior ones):

/Packages/<PackageDirectoryAndName>/Configuration/

The Configuration directory of each package is scanned first. Only at this stage new
configuration options must be introduced (by defining a default value).

/Configuration/

Configuration in the global Configuration directory overrides the default settings
defined in the package’s configuration directories.

There may exist a subdirectory for each application context (see Flow Bootstrap
section). This configuration is only loaded if Flow runs in the respective
application context.

/Configuration/<ApplicationContext>/

The context specific configuration again overrides the generic settings.

The configuration manager also considers custom contexts, such as Production/Live.
First, the base configuration is loaded, followed by the context specific configuration
for Production and Production/Live.

Flow’s configuration system does not support placing configuration files anywhere except
for in Configuration/ or one of the context directories in Configuration/. Flow
only supports three top-level contexts: Production, Development, and Testing. These
folders are reserved for the Flow configuration system.

Flow distinguishes between different types of configuration. The most important type of
configuration are the settings, however other configuration types exist for special
purposes.

The configuration format is YAML and the configuration options of each type are
defined in their own dedicated file:

Settings.yaml

Contains user-level settings, i.e. configuration options the users or administrators
are meant to change. Settings are the highest level of system configuration.
Settings have Split configuration sources enabled.

Routes.yaml

Contains routes configuration. This routing information is parsed and used by the MVC
Web Routing mechanism. Refer to the Routing chapter for more information.

Objects.yaml

Contains object configuration, i.e. options which configure objects and the
combination of those on a lower level. See the Object Framework chapter for more
information.

Policy.yaml

Contains the configuration of the security policies of the system. See the Security
chapter for details.

PackageStates.php

Contains a list of packages and their current state, for example if they are active
or not. Don’t edit this file directly, rather use the flow command line tool do
activate and deactivate packages.

Caches.yaml

Contains a list of caches which are registered automatically. Caches defined in this
configuration file are registered in an early stage of the boot process and profit
from mechanisms such as automatic flushing by the File Monitor. See the chapter about
the Cache Framework for details.

Views.yaml

Contains configurations for Views, for example the lookup paths for templates.
See the Model View Controller chapter for details.

The format of Flow’s configuration files is YAML. YAML is a well-readable format which is
especially well-suited for defining configuration. The full specification among with many
examples can be found on the YAML website. All important parts of the YAML
specification are supported by the parser used by Flow, it might happen though that some
exotic features won’t have the desired effect. At best you look at the configuration files
which come with the Flow distribution for getting more examples.

Sometimes it is necessary to use values in your configuration files which are defined as
PHP constants or are environment variables. These values can be included by special markers
which are replaced by the actual value during parse time. The format is %<CONSTANT_NAME>%
where <CONSTANT_NAME> is the name of a constant or %env:<ENVIRONMENT_VARIABLE>.
Note that the constant or environment variable name must be all uppercase.

Some examples:

%FLOW_PATH_WEB%

Will be replaced by the path to the public web directory.

%FLOW_PATH_DATA%

Will be replaced by the path to the /Data/ directory.

%PHP_VERSION%

Will be replaced by the current PHP version.

%Neos\Flow\Core\Bootstrap::MINIMUM_PHP_VERSION%

Will be replaced by this class constant’s value. Note that
a leading namespace backslash is generally allowed as of PHP,
but is not recommended due to CGL (stringed class names should not
have a leading backslash).

This will allow to use the new configuration type Views in the same way as the other types
supported by Flow natively, as soon as you have a file named Views.yaml in your configuration
folder(s). See Working with other configuration for details.

If you want to use a specific configuration processing type, you can pass it when registering
the configuration. The supported types are defined as CONFIGURATION_PROCESSING_TYPE_*
constants in ConfigurationManager.

In almost all cases, Flow will automatically provide you with the right configuration.

What you usually want to work with are settings, which are application-specific to
your package. The following example demonstrates how to let Flow inject the settings
of a classes’ package and output some option value:

Flow provides a way to inject specific settings through the InjectConfiguration annotation directly into your
properties.
The annotation provides three optional attributes related to configuration injection:

package specifies the package to get the configuration from. Defaults to the package the current class belongs to.

path specifies the path to the setting that should be injected. If it’s not set all settings of the current (or

type one of the ConfigurationManager::CONFIGURATION_TYPE_* constants to define where the configuration is fetched
from, defaults to ConfigurationManager::CONFIGURATION_TYPE_SETTINGS.

Note

As a best-practice for testing and extensibility you should also provide setters for
any setting you add to your class, although this is not required for the injection
to work.

Although infrequently necessary, it is also possible to retrieve options of the more
special configuration types. The ConfigurationManager provides a method called
getConfiguration() for this purpose. The result this method returns depends on the
actual configuration type you are requesting.

Bottom line is that you should be highly aware of what you’re doing when working with
these special options and that they might change in a later version of Flow. Usually
there are much better ways to get the desired information (e.g. ask the Object Manager for
object configuration).

Parsing the YAML configuration files takes a bit of time which remarkably slows down the
initialization of Flow. That’s why all configuration is cached by default, the
configuration manager will compile all loaded configuration into a PHP file which will be
loaded in subsequent calls instead of parsing the YAML files again.

Changes to the configuration are detected and the cache is flushed when needed. In order to
flush caches manually (should that be needed), use the following command:

Errors in configuration can lead to hard to spot errors and seemingly random
weird behavior. Flow therefore comes with a general purpose array validator
which can check PHP arrays for validity according to some schema.

The schema format is adapted from the JSON Schema standard;
currently the Parts 5.1 to 5.25 of the json-schema specification are implemented,
with the following deviations from the specification:

The “type” constraint is required for all properties.

The validator only executes the checks that make sense for a specific type,
see list of possible constraints below.

The “format” constraint for string type has additional class-name and
instance-name options.

The “dependencies” constraint of the spec is not implemented.

Similar to “patternProperties” “formatProperties” can be specified specified
for dictionaries

Warning

While the configuration:validate command will stay like it is, the inner workings
of the schema validation are still subject to change. The location of schema files
and the syntax might be adjusted in the future, as we (and you) gather real-world
experience with this.

With that out of the way: feel free to create custom schemata and let us know
of any issues you find or suggestion you have!

The schemas are searched in the path Resources/Private/Schema of all active
Packages. The schema-filenames must match the pattern
<type>.<path>.schema.yaml. The type and/or the path can also be expressed
as subdirectories of Resources/Private/Schema. So
Settings/Neos/Flow.persistence.schema.yaml will match the same paths as
Settings.Neos.Flow.persistence.schema.yaml or
Settings/Neos.Flow/persistence.schema.yaml.