Layering and naming rules
This page is for developers who add code to Exponential 6.0.x or to an extension, and for reviewers who check such changes. It answers where a piece of code belongs, which layers it may call, and what to name it. Each rule says must (a review rejects the change) or should (the expected default), shows how the code base implements it, and lists the places that do not follow it yet. The counts on this page were taken from the repository in October 2026; they are evidence, not limits.
The layers
extension/<name>/ plugins: settings, modules, designs, classes, cronjobs
| may use everything below, through the documented extension points
design/<design>/templates presentation (.tpl), stylesheets, javascript
| reads data only through fetch functions and template operators
kernel/<module>/ controllers: module.php, view entry files, function_definition.php
|
kernel/private/ internal API: ezpKernel, views, commands, cronjobs, services, REST, ezpEvent
|
kernel/classes/ domain: content, users, roles, datatypes, workflows, caches, persistence
|
lib/ generic libraries: eZDB, eZINI, eZTemplate, eZFile, eZSys, eZModule, sessionsA layer may call the layers below it. Calls upward are the exceptions listed per layer.
lib/: generic libraries
Purpose. Infrastructure that does not know about content: lib/ezdb (database drivers), lib/ezdbschema,
lib/ezutils (eZINI, eZSys, eZModule, eZExtension, eZHTTPTool, eZFunctionHandler, eZDebug),
lib/eztemplate (eZTemplate and the base operators), lib/ezfile, lib/ezi18n, lib/ezimage, lib/ezlocale,
lib/ezsession, lib/ezsoap, lib/ezpdf, lib/ezdiff, lib/ezmath.
Rule. New code in lib/ should not depend on kernel/ classes. It must not depend on a module or a
design.
Status of the rule: not met everywhere. The libraries were written together with the kernel and several call it. Examples found in the code:
File in lib/ | Kernel dependency |
|---|---|
lib/eztemplate/classes/eztemplateroleoperator.php | eZUser::currentUserID(), instanceof eZRole |
lib/eztemplate/classes/eztemplatecacheblock.php | eZClusterFileHandler::instance() (kernel/classes/ezclusterfilehandler.php) |
lib/ezutils/classes/ezexpiryhandler.php | eZClusterFileHandler::instance() |
lib/ezutils/classes/ezdebug.php | eZUser::currentUserID() |
lib/ezutils/classes/ezoperationmemento.php, ezhttppersistence.php | eZPersistentObject (kernel/classes/ezpersistentobject.php) |
lib/ezdb/classes/expmongodb.php, lib/ezdbschema/classes/expmongoschema.php | eZPersistentObject, eZUser |
In total 8 files in lib/ name eZUser, 8 name eZClusterFileHandler and 4 name eZPersistentObject. Treat
lib/ as "lower level than the kernel", not as an independent library set. A change should not add new
dependencies of this kind; moving the existing ones is open debt.
kernel/classes/: the domain
Purpose. The content model and everything around it: eZContentObject, eZContentObjectTreeNode,
eZContentClass, eZRole, eZPolicy, eZPersistentObject, the datatypes in kernel/classes/datatypes/, the
workflow types in kernel/classes/workflowtypes/, notification handlers, caches (eZCache,
eZContentCacheManager), cluster file handlers, and newer subsystems in subdirectories (for example
kernel/classes/audit/).
Rule. Domain classes must not render pages or read request input; they take values as parameters and return objects or arrays. They should be reachable from a view, a command and a cronjob alike.
kernel/<module>/: controllers
Purpose. module.php (views and policy functions), function_definition.php (template fetches), the view entry
files and, for older modules, the view code itself.
Rule. A view reads input through eZHTTPTool (eZHTTPTool::instance(), hasPostVariable(),
postVariable()), relies on the form token check of the ezformtoken extension for POST requests, calls the domain layer, and renders through
eZTemplate::factory(). It must not print HTML itself except for downloads and JSON responses.
Exceptions. 185 of the 255 view classes in kernel/private/classes/views/ use eZHTTPTool::instance(); 10 still
read $_POST or $_GET directly (for example kernel/private/classes/views/content/multiedit.php,
contentcheck/fixfiles.php, contentfinder/action.php).
kernel/private/: internal API
Purpose. Code that is not a public extension API, or that the kernel owns end to end: ezpKernel and
ezpKernelWeb, ezpEvent, the class-based views, commands and cronjob parts
(kernel/private/classes/{views,commands,cronjobs}/, namespaces Exponential\View\Kernel,
Exponential\Command\Kernel, Exponential\Cronjob\Kernel), shared services (kernel/private/classes/services/,
namespace Exponential\Service), the REST layer (kernel/private/rest/, kernel/private/api/, OAuth in
kernel/private/oauth/ and the modules oauth and oauthadmin in kernel/private/modules/), the cluster file
handler eZDFSFileHandler and kernel interfaces (kernel/private/interfaces/).
Rule. Extensions should use the documented extension points (settings, [RunnableSettings],
[Event] Listeners[]) rather than call kernel/private classes directly; their signatures may change between
releases. Work shared by a view, a command and a cronjob part goes into a service class, not into one of them
(Commands, cronjob parts and module views as classes).
design/: presentation
Purpose. Templates, stylesheets, scripts and images per design: design/standard, design/admin,
design/admin3, design/admin4, design/admin4l, design/base, design/editor, design/plain and others.
Rules.
- Templates do not query the database. The template language has no SQL construct. Data comes from fetch
functions (
kernel/<module>/function_definition.php, run byeZFunctionHandler) and template operators, which apply permissions in PHP. A template must not receive a raw database handle. Exception in practice: an operator is PHP and can query, so operators are reviewed like views (eztemplateroleoperator.phpreads roles througheZRole). - No inline CSS in administration templates. No
<style>element and nostyle=""attribute in the templates ofadmin,admin3,admin4andadmin4l; all CSS lives in the design'sstylesheets/directory and is loaded through the stylesheet settings so the packer bundles it. Colors, radii, spacing and fonts come from the design tokens (--a4-*), and every color token has a dark-mode value. Enforced bytests/tests/design/AdminStylingRulesTest.php(DB-less):ALLOWLISTis empty, and the single permanent entry inEXCEPTIONSisdesign/admin/templates/pagelayout.tpl(column widths applied before the page is drawn). The test also checks thatstylesheets/modules/*.cssuse only tokens and thatcomponents.cssis the same inadminandadmin4. Reference: Styling the administration. - No inline script in the administration. The administration runs under a Content Security Policy without
'unsafe-inline'(site.ini [ContentSecurityPolicy]; report-only on the administration by default). Templates rendered byadmin4andadmin4lcarry no inline<script>with code, noon...=attribute and nojavascript:URL; enforced bytests/tests/design/AdminContentSecurityPolicyTest.phpand, for the shipped extensions,tests/tests/design/ExtensionInlineScriptsTest.php. Script code goes indesign/<design>/javascript/(for exampledesign/admin4/javascript/admin4.js). - Nonce for the scripts that must stay inline. With
[ContentSecurityPolicy] Nonce=enabled, each request gets a nonce added to the directives ofNonceDirectives[](script-srcshipped); a template prints it with the operatorcsp_nonce()(expContentSecurityPolicyOperator, registered inkernel/common/eztemplateautoload.php):<script nonce="{csp_nonce()}">. See Content Security Policy. - Output is escaped. Every variable from content or input is printed with
|wash(or an operator that escapes).
extension/: plugins
Purpose. Everything that is not the kernel: extension/<name>/ with ezinfo.php, extension.xml,
settings/, modules/, design/, classes/, autoloads/, cronjobs/, translations/, bin/php/.
Rule. An extension must not require changes to kernel files. It is switched on in
site.ini [ExtensionSettings] ActiveExtensions[] or ActiveAccessExtensions[], and its classes are found after
php bin/php/ezpgenerateautoloads.php -e. Extension class-based code uses the namespaces
Exponential\Command\Extension\<Ext>, Exponential\Cronjob\Extension\<Ext> and
Exponential\View\Extension\<Ext>\<Module>.
Cross-cutting rules
- Settings are read through
eZINIonly.eZINI::instance( 'file.ini' )->variable( 'Section', 'Setting' ). No code inkernel/,lib/orbin/callsparse_ini_file()orparse_ini_string(). Settings are written with./console exp:inioreZINI::save(), never by string replacement in a script (exp:ini). - Debug output through
eZDebug.eZDebug::writeError(),writeWarning(),writeNotice(); noechoorvar_dumpleft in kernel code. - Translations through
ezpI18n::tr( $context, $text )in PHP andi18n( $context )in templates. - Persistent workers. Code must assume it can run in a long-lived Velocity worker (see Kernel architecture).
Naming conventions
The exp prefix for new code, identifiers kept
The product is Exponential; the code base inherited its identifiers from eZ Publish 4. The rules:
- New classes, modules, template operators, templates, settings files and translation contexts should use
exp/Exp:expAudit(kernel/classes/audit/expaudit.php),expContentSecurityPolicy(kernel/private/classes/expcontentsecuritypolicy.php),expInfo(lib/ezutils/classes/expinfo.php),expMongoDB, theexphelpmodule andsettings/exphelp.ini. There are more than 330exp-prefixed class declarations inkernel/andlib/. - Existing
eZ*andezp*identifiers (eZContentObject,eZINI,ezpKernel), table names, file paths and setting names must never be renamed: extensions and sites depend on them. The 2026 rebranding changed only text that people read (The product is called Exponential). - Text for people (UI strings, documentation, commit messages) uses the name Exponential.
sevenxandexpare both 7x prefixes.sevenxis 7x's official public PHP code prefix (an identifier cannot start with a digit, so "7x" cannot be one); extensions and classes from 7x usesevenxorexpas 7x needs;expis used with intent to build the Exponential brand and to assign ownership to the Exponential project and the Exponential Foundation. The full rule: Naming prefixes: sevenx and exp.
Exceptions (added before the rule was applied consistently). Kernel modules added in 2026 without the prefix:
apikey, audit, contentcheck, contentfinder, csp, mailpreferences, uiswitch (only exphelp has it).
Template operators csp_nonce and audit_label (while exp_environment has it). The class ezpRepairQueue
(lib/ezutils/classes/ezprepairqueue.php) uses the old ezp prefix. These stay as they are: renaming them now would
itself be a break.
Classes and files
- One class per file; the file name is the class name in lower case:
expContentSecurityPolicyinexpcontentsecuritypolicy.php,ezpKernelWebinezpkernelweb.php. - Namespaced runnable classes follow the path instead:
Exponential\View\Kernel\Content\Viewinkernel/private/classes/views/content/view.php. - After adding or renaming a class, regenerate the class maps (
php bin/php/ezpgenerateautoloads.php -efor extensions,-kfor the kernel with.autoloadignoreor--excludefor working copies inside the root).
Extensions
Lower-case directory names under extension/. New extensions should start with exp; the extensions shipped in
the repository keep their names: ezjscore, ezoe and ezformtoken the historical ones, expservices already the new prefix. The Info_url and
<info_url> point at the extension's public repository (extension metadata).
INI files, sections and settings
- File names lower case:
settings/<name>.ini; overrides<name>.ini.append.php. - Sections in CamelCase, usually ending in
Settings:[SiteAccessSettings],[DataTypeSettings],[HelpSettings],[DeploySettings]; dynamic sections use a dash:[CronjobPart-frequent]. - Settings in CamelCase:
MatchOrder,AvailableDataTypes[],ExtensionDirectories[]; arrays end in[](List[]), hashes useName[key]=value. - Switches use
enabled/disabled(ViewCaching=enabled); some older settings usetrue/false(ForceVirtualHost=false). A new setting should useenabled/disabled. - Every new setting gets a comment above it in the shipped file and a safe default.
Templates
design/<design>/templates/<module>/<view>.tplfor module views (design/admin4/templates/exphelp/viewer.tpl).- Reusable pieces in a
parts/subdirectory (design/admin4/templates/exphelp/parts/); page-wide pieces aspage_<name>.tpl(page_header.tpl,page_mainarea.tpl). - Datatype templates under
content/datatype/view/andcontent/datatype/edit/named after the datatype string. - Overrides under
override/templates/, mapped inoverride.ini.
CSS and JavaScript
- Administration CSS classes use the design prefix:
.a4-*inadmin4(.a4-card,.a4-btn,.a4-table), one extra segment for a module (.a4-help-*indesign/admin4/stylesheets/modules/help.cssandadmin4.css). No per-module prefixes outside the design prefix. - Tokens are CSS custom properties
--a4-*; module CSS lives indesign/admin4/stylesheets/modules/<group>.css(content,help,people,setup,structure,workflow). - Script files are named after their purpose in lower case with
_or-(a4_mega_menu.js,exphelp.js).
Database tables
Kernel tables keep the ez prefix (118 of the tables in share/db_schema.dba). Tables added in 2026 use exp:
expaudit_cursor, expaudit_event, expaudit_file, expmail_category, expmail_consent_log, expmail_pending,
expmail_preference, expmail_suppression, expbookmark_folder, expapikey. Names are lower case with _.
Columns added to existing ez tables keep the table's style (for example ezcontentobject_trash.trashed_by).
Translation contexts
Contexts are the path of the code that uses them: kernel/<module> for PHP views
(ezpI18n::tr( 'kernel/exphelp', 'Search' )) and design/<design>/<module>/<view> for templates. The translation
files are share/translations/<locale>/translation.ts (plus share/translations/untranslated/); new strings
must be added to the context the code uses so exp:i18n and the translation tests find them.
Console commands
bin/php/<name>.phpisexp:<name>automatically; a script adds readable names with@aliasin its docblock, using:between words:exp:help(bin/php/exphelp.php),exp:help:content,exp:access:check,exp:mail:status. Velocity isexp:velocitywith subcommands (exp:velocity deploy,exp:velocity cache clear).- Extension scripts are
ext:<ext>:<name>; cronjob partscron:<part>. - Command names, options and exit codes are part of the compatibility promise (Compatibility, releases and deployment).
Known gaps
lib/depends on kernel classes in at least the files listed above.- Seven 2026 kernel modules and two operators do not carry the
expprefix. - Ten view classes read superglobals directly.
- INI switches mix
enabled/disabledandtrue/false. - The rules for designs are enforced by tests for the administration designs only; site designs are not checked for inline CSS.