Lesson 8.1: How settings are read
Almost every behavior of Exponential is a setting in an .ini file, and the same setting can be written in many
files. This lesson explains the file format, the order in which the files are read, and how arrays add up, so that
learners can answer the everyday question "where does this value come from?" in one command.
At a glance
| Course | Developers |
| Module | Module 8: Settings and siteaccesses |
| Duration | 45 minutes (20 presenting, 25 exercise) |
| Level | Intermediate |
| Audience | Developers and administrators |
| Prerequisites | Module 7 |
Learning objectives
After this lesson, learners can:
- read the format of
settings/site.iniand of an.ini.append.phpfile; - name the scopes and the order in which they are read;
- explain how arrays add up, what the reset line
Variable[]does, and how hash entries are written; - trace a value with
exp:ini whereand on the settings page of the administration.
Trainer's notes
How to present it
Sources: Specification: INI override directories and placements, console exp:ini and The settings page.
- The format (4 minutes).
settings/site.iniholds the defaults:[Block]lines andVariable=valuelines;#starts a comment. An.ini.append.phpfile has the same content inside<?php /* #?ini charset="utf-8"?and*/ ?>, so a web server never shows it as text. - The order (5 minutes).
settings/<file>.inifirst, then the override directories.eZINImerges them in the scope ordersa-extension,siteaccess,extension,override: a later file wins. Sosettings/override/(the global scope) wins over everything; a setting in an extension's rootsettings/wins oversettings/siteaccess/<sa>/when the extension is inActiveExtensions[], not when it is inActiveAccessExtensions[]. - Arrays (4 minutes).
List[]=ain one file andList[]=bin a later one givea, b. The lineList[]alone resets the array: values of earlier files are dropped. A hash entry isList[key]=value. - The tools (4 minutes).
exp:ini where <file>/<Block>/<Variable> [<sa>]lists every file in load order and the value in effect, and lists files of inactive extensions separately. In the administration, Setup > Ini settings shows every value with the file it comes from. - Caches (2 minutes). Settings are cached;
config.phpturns off the file time check, so a hand edit is seen only afterphp bin/php/ezcache.php --clear-tag=ini.exp:iniclears it after each write.
Common questions
Why does my siteaccess setting not win? The same variable is set in settings/override/ or in an active
extension's root settings/, which are read later. exp:ini where shows it.
Can a setting differ per machine? Yes: Settings per environment
adds variant files such as site.ini.test.append.php, chosen by the constant EXP_ENV.
Are settings files secret? Some hold database passwords. exp:ini and the settings page mask values whose
names look like secrets.
Pitfalls
- Editing
settings/site.ini. It is the kernel's default file and is replaced at every update. Write overrides. - A forgotten reset line. An array without
Variable[]keeps the values of earlier files; with it, it drops them. Both are intended in different places; read the result withwhere. - Hand edits without clearing the INI cache. The old value stays in effect.
Hands-on exercise
On the development installation.
- Open
settings/site.iniand find the block[SiteSettings]and the variableSiteName. - Trace it:
php bin/php/console exp:ini where site.ini/SiteSettings/SiteName <sa>. - Trace an array:
php bin/php/console exp:ini where site.ini/ExtensionSettings/ActiveExtensions. Count how many files add to it. - Find a reset line in the defaults:
grep -n "^AvailableSiteAccessList\[\]$" settings/site.ini. It starts the array empty; overrides then add the siteaccesses of this installation. - List the variables of a block in effect:
php bin/php/console exp:ini list site.ini/DebugSettings. - List the blocks of the global override:
php bin/php/console exp:ini list site.ini global. Notice masked values, if any. - In the administration, open Setup > Ini settings, choose
site.iniand findSiteNamewith the file it comes from. - Write down, for one setting of your choice, the files in load order and the value in effect.
Expected result
- Step 2:
settings/site.iniwith the default, the siteaccess file with the site's name, andIn effect:. - Step 3: several files, some from extensions; arrays add up.
- Step 6: secrets such as passwords appear as
********. - Step 7: the same value and file as step 2.
- The trainer checks step 8 for two learners.
Quiz
- What wraps the content of an
.ini.append.phpfile, and why? - Which file wins:
settings/siteaccess/site/site.ini.append.phporsettings/override/site.ini.append.php? A. The siteaccess file B. The override file C. The one changed last D. Neither: they are merged by name - What does the line
ActiveExtensions[]alone do? - Which command lists every file that sets a variable, in load order?
- Why is a hand edit of a settings file not seen at once?
Answers
<?php /* ... */ ?>, so the web server runs it as PHP and never shows the settings as text.- B. The override (global) scope is read last and wins.
- It resets the array: values from files read earlier are dropped.
exp:ini where <file>/<Block>/<Variable>.- Settings are cached and
config.phpturns off the file time check; clear theinicache tag.
Further reading
- Specification: INI override directories and placements.
- The settings page: reading and changing settings in the administration.
- Settings per environment.
Related pages
- Module 8: Settings and siteaccesses
- Developers: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.