webcoast/typo3-context-config-loader

Easy to use configuration loader for loading context specific configuration

v2.0.0 2023-09-11 10:31 UTC

This package is auto-updated.

Last update: 2024-10-11 12:57:58 UTC


README

A loader to make it easy to include context specific additional configuration files inside typo3conf/AdditionalConfiguration.php.

This loader can

  • load additional configuration from the current root and sub context
  • load local configuration files containing credentials
  • load a default configuration with non-standard settings (which would be removed from LocalConfiguration.php on each write)
  • read database credentials from a .my.cnf file.

Installation

Require via composer

composer req webcoast/typo3-config-loader

Usage

Put this inside your typo3conf/AdditionalConfiguration.php

(new \WEBcoast\Typo3ConfigLoader\Loader())->load();

This will automatically include configuration with standard settings (see below).

To adjust the behavior call the according setter function on the loader instance, e.g.

(new \WEBcoast\Typo3ConfigLoader\Loader())
    ->setIncludeDefaultConfiguration(true)
    ->setUseFolderPerContext(true)
    ->setIncludeMyCnf(true)
    ->setConfigFileSuffix('AdditionalConfiguration')
    ->load();

This loader does not parse different configuration formats like PHP, XML or YAML. It just requires the PHP files for the different context. The only file that is actually parsed is the .my.cnf file, if enabled. This gives you the freedom to do whatever you want inside those PHP files.

Order of inclusion

  1. Default.php (if enabled)
  2. .my.cnf (if enabled; parent context is applied first, if inheritance is enabled)
  3. Context specific PHP files (parent context is applied first, if inheritance is enabled)
  4. Local context specific PHP files (if enabled; parent context is applied first, if inheritance is enabled)

Settings

License

See the license file.

Contribution

Open an issue or fork and provide a pull request.