Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,090 of 9,090 pages
About the help in other languages
All help pages

Settings in an extension

Settings an extension ships: registration lines in kernel INI files, your own INI file with documented defaults, reading it safely with eZINI, per-siteaccess settings and secrets.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/extension-development/part-3-extension-developer/settings-in-an-extension.md

On this page

Settings in an extension

Part 3, chapter 7. Almost every extension has a settings/ folder. It does two things: it registers the extension's parts with the kernel (modules, designs, datatypes...), and it ships the extension's own options with sensible defaults. This chapter covers both.

Registration settings

These are lines in kernel INI files that point the kernel at your extension. A typical set:

settings/module.ini.append.php:

<?php /* #?ini charset="utf-8"?

[ModuleSettings]
ExtensionRepositories[]=mysite_hello

*/ ?>

settings/design.ini.append.php:

<?php /* #?ini charset="utf-8"?

[ExtensionSettings]
DesignExtensions[]=mysite_hello

*/ ?>

settings/site.ini.append.php (template operators):

<?php /* #?ini charset="utf-8"?

[TemplateSettings]
ExtensionAutoloadPath[]=mysite_hello

*/ ?>

The full table of registration settings is in The extension directory layout. They are read only while the extension is active, because only an active extension's settings/ is an override directory.

Your own settings file

Give your options their own file named after the extension, settings/mysite_hello.ini.append.php, with every option documented and given a safe default:

<?php /* #?ini charset="utf-8"?

[HelloSettings]
# The greeting shown when no name is given.
DefaultName=world
# How many greetings the list view shows at most.
ListLimit=10
# Names that may not be greeted (one per line).
BlockedNames[]

*/ ?>

In a settings directory the kernel reads <file>, <file>.php, <file>.append.php and the deprecated <file>.append (eZINI in lib/ezutils/classes/ezini.php). Use <file>.append.php, as every shipped extension does; it protects the file from being served to a browser.

An installation changes your options without touching your extension, in its override or siteaccess directory:

./console exp:ini set mysite_hello.ini/HelloSettings/ListLimit 25 global

Reading settings in PHP

<?php
$ini = eZINI::instance( 'mysite_hello.ini' );

$name  = $ini->variable( 'HelloSettings', 'DefaultName' );
$limit = $ini->hasVariable( 'HelloSettings', 'ListLimit' )
       ? (int)$ini->variable( 'HelloSettings', 'ListLimit' )
       : 10;
$blocked = $ini->variable( 'HelloSettings', 'BlockedNames' );   // an array
RuleWhy
Use hasVariable() before variable() for optional settingsa missing variable or block is written to the error log ("Undefined variable ... in group ...") and variable() returns false
Cast numbers ((int))values are strings
Compare switches with the exact string (=== 'enabled')there is no boolean type in INI
Never cache an eZINI value in a static property of your ownunder a persistent server (Velocity) a static outlives the request; eZINI handles its own cache

eZINI::instance( $fileName = 'site.ini', $rootDir = 'settings', ... ) is the signature; the defaults are what you want almost always. The full API is in eZINI: reading settings.

Reading settings in templates

{ezini( 'HelloSettings', 'DefaultName', 'mysite_hello.ini' )|wash}

Per-siteaccess settings in an extension

An extension can carry settings for a siteaccess in settings/siteaccess/<sa>/, and group settings in settings/override__<group>/. See Settings scopes and the order they win in.

Secrets

An extension that needs an API key ships the setting empty with a comment, and the installation fills it in settings/override/. Name it so it is masked (...Key, Token, Secret, Password). Never commit a real key; the package download refuses to pack an extension that holds one (the secret check).

Settings the RAD tools write

The Settings extension wizard (/setup/settingsextension) writes a settings-only extension, including event listeners and siteaccess customization points; exp:ini move-all ... --create-extension moves existing settings into one. See With RAD: a settings-only extension.

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.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x