TYPO3 ver. 6.x - additional configuration a.k.a. `localconf_local.php`
Asked Answered
M

2

11

What we need

In TYPO3 ver. 4.x we used to include additional configuration file for overwriting some settings (ie. DB credentials) by adding the include statement at the end of the localconf.php:

@include_once('localconf_local.php');

Thanks to this trick it is possible for an example keep separate database settings or IM paths individual for each developer as we can just ignore our 'local' files from the git repository.

What's the problem

Unfortunately in TYPO3 ver. 6.x that approach requires manual changes of the LocalConfiguration.php to overwrite the values before the return statement, what's more after each operation in Install Tool (or Extension Manager) the file is completely to original syntax (so we need to change it again and again...

Question

Have you guys any workaround for this? Or this is just... impossible to do?

Miramirabeau answered 21/8, 2013 at 6:24 Comment(0)
M
30

Got it! :)

The answer is: typo3conf/AdditionalConfiguration.php if this file exists it's included automatically, to overwrite some values we need to use well-known syntax ie.:

<?php
$GLOBALS['TYPO3_CONF_VARS']['DB']['database'] = 'my_local_database';
$GLOBALS['TYPO3_CONF_VARS']['DB']['host']     = 'localhost';
$GLOBALS['TYPO3_CONF_VARS']['DB']['username'] = 'username';
$GLOBALS['TYPO3_CONF_VARS']['DB']['password'] = 'mypassword';
?>

From "What's new" SlideShare (page 33)

Miramirabeau answered 21/8, 2013 at 6:50 Comment(3)
Also listed on docs.typo3.org/typo3cms/InstallationGuide/In-depth/…Equation
@cweiske, that link has gone stale. Currently this seems to be the page you want to link to: docs.typo3.org/typo3cms/InstallationGuide/In-depth/…Quadrature
The configuration for DB settings slightly changed in TYPO3 9.5.x due to changed DB configuration: $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'][...]. For the correct fields have a look into the LocalConfiguration.php.Rudimentary
K
3

In addition to your own answer pay attention to a fact, that from 6.0 you shouldn't access TYPO3_CONF_VARS directly in your extension, but by getLocalConfigurationValueByPath('BE/loginSecurityLevel') and setLocalConfigurationValueByPath('BE/loginSecurityLevel', 'rsa') in \TYPO3\CMS\Core\Configuration\ConfigurationManager class.

Taken from same "What's new" SlideShare page 35.

UPDATE 15.06.15: Page 35 was included by accident to slides. Since TYPO3 6.2 ConfigurationManager is marked @internal. So, you shouldn't use ConfigurationManager in your own code. Details

Kessiah answered 21/8, 2013 at 8:16 Comment(2)
But according to a bug report the methods you mentioned aren't meant to be used in the AdditionalConfiguration.php file or outside of the core.Shy
@Shy Thank you for pointing out. I've updated my answer, so others know, taht this solution shouldn't be used.Kessiah

© 2022 - 2024 — McMap. All rights reserved.