This extension include PHP files based on TYPO3_CONTEXT value. This allows you to make fine tuning of TYPO3 settings based on different context: instance, feature activation, system verbosity etc.
Install using composer:
composer require sourcebroker/configs
Add following code in
typo3conf/AdditionalConfiguration.php
<?php defined('TYPO3') or die(); \SourceBroker\ConfigTypo3\Config::initialize() ->appendContextToSiteName() ->includeContextDependentConfigurationFiles();
Create folder
context
in folderconfig
.In folder
context
create folders that starts with 1_*, 2_*, 3_*, 4_*., example1_verbosity
,2_mode
,3_instance
Inside those folders create php files with the names you will use in TYPO3_CONTEXT.
- Copy example configs from
Resources/Private/Examples/Example1/context
to folderconfig/context
- You can change the folder names
1_verbosity
,2_mode
,3_instance
to whatever you want but do not change thenumber_underscore
pair. Numbers decide about what part of configs to read from the folders based on TYPO3_CONTEXT parts. Part after number and underscore play no role. - If TYPO3_CONTEXT will be set to
Development/Staging/Beta
then fileDevelopment.php
will be included from folder1_verbosity
, fileStaging.php
will be included from folder2_mode
and fileBeta.php
will be included from folder3_instance
.
You can have as many folders with numbers as you like. You can also read more files from one folder when you separate string with comma.
For example you can set TYPO3_CONTEXT to Production//Live/Feature1,Feature2
then file Production.php
will be included from folder
1_verbosity
, file Live.php
will be included from folder 3_mode
and file Feature1.php
, Feature2.php
will be included
from folder 4_whatever
.
If you install package helhum/dotenv-connector
then you additionally have possibility to modify
$GLOBALS['TYPO3_CONF_VARS']
array by adding entries in .env
file with following convention:
TYPO3__[first_level_array]__[second_level_array]__[third_level_array] = "value"
This allows you to provide database values per instance by putting following lines to .env files of each instance.
The .env
file should be out of git.
Example:
TYPO3__DB__Connections__Default__dbname=".." TYPO3__DB__Connections__Default__host=".." TYPO3__DB__Connections__Default__port=".." TYPO3__DB__Connections__Default__user=".." TYPO3__DB__Connections__Default__password=".." TYPO3__GFX__processor_path=".." TYPO3__GFX__processor_path_lzw=".." TYPO3__GFX__processor_colorspace=".."
It is up to you to decide what values to put inside .env
(which is out of git) and which
to config/context/3_instance/Live.php
, config/context/3_instance/Beta.php
etc which are inside git.
Lot of values stored in .env
file means that it is harder to recreate the same TYPO3 state on local development system.
If those settings are in git then you can just switch TYPO3_CONTEXT from local TYPO3_CONTEXT=Development/Staging/Local
to beta TYPO3_CONTEXT=Production/Staging/Beta
on local development system.
Database access data are good candidate to be put inside .env.
You can use following code to disable uncaching on development for some cache configurations:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['configs']['caching']['cacheConfigurations']['my_cache']['uncache'] = false
- Extension https://github.com/b13/typo3-config