0

In TYPO3, Version 6.1.5, I'd like to split my configuration in typo3conf in three parts:

  1. One part generated by the install-tool, under version control.
  2. One manually managed part, under version control.
  3. One manually managed part, containing server specific stuff, not under version control. Contains e.g. database credentials.

I've tried to do it like this:

  1. is done using LocalConfiguration.php,
  2. is done using AdditionalConfiguration.php
  3. is done by and additional file, included by the AdditionalConfiguration.php.

This does not work, as it seams that the files are evaluated in this order:

  1. LocalConfiguration.php
  2. AddtitionalConfiguration.php
  3. LocalConfiguration.php

So the changes from my server specific file (and AdditionalConfiguration.php) are simple overwritten by the stuff from LocalConfiguration.php.

Any idea how to get around something like this?

biesior
  • 55,576
  • 10
  • 125
  • 182
Jost
  • 5,948
  • 8
  • 42
  • 72

2 Answers2

1

First: don't apply any manual changes in your: LocalConfiguration.php file as it will be removed after each operation in the Install Tool, Extension Manager etc.

For adding custom configuration, you should use AddtitionalConfiguration.php file which isn't changed (as probably you know while you are using it). In this additional conf you need to use 'old' syntax for overwriting values, ie:

<?php
$GLOBALS['TYPO3_CONF_VARS']['DB']['database']='some_db_loc';
$GLOBALS['TYPO3_CONF_VARS']['DB']['host']='localhost';
$GLOBALS['TYPO3_CONF_VARS']['DB']['username']='jost';
$GLOBALS['TYPO3_CONF_VARS']['DB']['password']='yourpass';

finally at the end of the additional conf use common include() for including next PHP file in which you can overwrite these values again:

@include('jost_localconf_dont_commit.php');

At least in TYPO3 ver. 6.1.1 this scenario works like a charm.

EDIT: also take a look at Viktor's answer according to accessing the properties in additional config.

BTW: I'm not really sure why you need to commit AdditionalConfiguration.php , IMHO it should be ignored in the git, and on every environment it should have this file filled with local data typical for this env. Main (production) instance should keep whole its config in LocalConfiguration.php

Community
  • 1
  • 1
biesior
  • 55,576
  • 10
  • 125
  • 182
  • Thanks, this solved it. You describe exactly my setup (wrote the settings like Viktor recommended), but it didn't seem to work due to the following behavior: If you change `AdditionalConfiguration.php`, the changes will only be reflected after reloading the install tool (or page?) **twice**. The first time the changes are copied to `LocalConfiguration.php` (but not applied), the second time they are actually used. Regarding the usage of `AdditionalConfiguration.php`, I'm also not sure if I'll ever use it - but I want to keep the option of using it. – Jost Sep 16 '13 at 16:34
1

Just one things to add to biesior's answer:

For security reasons, it is even better not to have the DB credentials in AdditionalConfiguration.php. It's better to include a PHP file with the credentials from a path that is outside the document root of the host. Therefore if PHP doesn't work properly, the file cannot be downloaded and the DB credentials are not exposed.

lorenz
  • 4,538
  • 1
  • 27
  • 45
  • You are right - but this won't work in TYPO3. Data from the `AdditionalConfiguration.php` (or included files) is copied to the `LocalConfiguration.php`, which has to be in the document root. – Jost Sep 17 '13 at 05:46
  • @Jost Data from AdditionalConfiguration.php is not copied into LocalConfiguration.php anymore. (Using TYPO3 6.2) – Martin Krung Nov 10 '15 at 09:16
  • @FabianThommen Actually, it was never copied - Back when I wrote that comment, I used a `ConfigurationManager` in my AdditionalConfiguration.php, and that manager rewrote the LocalConfiguration.php on every change. I've since learned that this manager is internal API. – Jost Nov 10 '15 at 18:07