Skip to content

Exponential CMS

Writing an extension

The structure of an extension, its settings and metadata, activation, autoloading, and a first module.

An extension is a folder under extension/ that adds settings, templates, modules, content types, commands or cronjobs to Exponential without touching the kernel. It does nothing until it is switched on.

How extensions work

  • The folder is named after the extension, for example extension/myhello.
  • site.ini [ExtensionSettings] ActiveExtensions[] switches it on for the installation; ActiveAccessExtensions[] for one siteaccess.
  • The order of the list is the order of priority: an extension loaded earlier wins for settings and design templates.
  • Classes in its classes/ folder are found through an autoload array that you regenerate with php bin/php/ezpgenerateautoloads.php -e.
  • Its default settings are .ini.append.php files in extension/<name>/settings/.
  • It describes itself in ezinfo.php and extension.xml, which Setup > Extensions and the about page read.

The smallest working extension

mkdir -p extension/myhello/settings extension/myhello/modules/hello \
         extension/myhello/design/standard/templates/hello
  • ezinfo.php: a class myhelloInfo with a static info() that returns Name, Version, Copyright, License and Info_url.
  • extension.xml: the same name, version, license and info_url under <metadata>. Keep the two versions equal.
  • settings/module.ini.append.php: [ModuleSettings] ExtensionRepositories[]=myhello, so the kernel looks for modules here.
  • settings/design.ini.append.php: [ExtensionSettings] DesignExtensions[]=myhello, so the template system looks in this design.
  • modules/hello/module.php: the module, with $ViewList['world'] pointing at world.php and a parameter Name.
  • design/standard/templates/hello/world.tpl: the template the view renders.

The settings files are wrapped in <?php /* #?ini charset="utf-8"? ... */ ?>, like every .ini.append.php file.

Switch it on

php -l extension/myhello/ezinfo.php
php -l extension/myhello/modules/hello/module.php
php -l extension/myhello/modules/hello/world.php
./console exp:ini add 'site.ini/ExtensionSettings/ActiveExtensions[]' myhello global
php bin/php/ezpgenerateautoloads.php -e
php bin/php/ezcache.php --clear-all

Open /hello/world/Ada on your site: the page shows Hello, Ada inside the site's layout, and Setup > Extensions lists My Hello with version 0.1.0. On a site served by Velocity, redeploy so the workers see the new classes.

Note: A view without a functions entry has no access control: anyone who can reach the site can open it. Before it shows anything private, declare a function in module.php ($FunctionList['read'] = array();), name it on the view ('functions' => array( 'read' )), and grant it in Users > Roles and policies.

Configure without editing

Never edit an extension's own settings. Override them in a place that survives an upgrade, for example with the console:

./console exp:ini where site.ini/ExtensionSettings/ActiveExtensions
./console exp:ini set site.ini/SiteSettings/SiteName "My site" siteaccess:site

More an extension can bring

  • Console commands: extension/<ext>/bin/php/<name>.php becomes ext:<ext>:<name>.
  • Cronjob parts in settings/cronjob.ini.append.php.
  • Migrations in extension/<name>/migrations/. See Migrations.
  • A Composer package of type ezpublish-legacy-extension, so others can install it with composer require.

Note: Never commit settings/override/: it can hold passwords.

Last updated 11/26/2026. Something missing or wrong? Write to info@se7enx.com.