Packages: extensions, Composer and bundles
This page is for developers who structure code as bundles, packages, apps or engines. In Exponential that unit is the
extension: a directory in extension/<name>/ that can carry modules, classes, templates, settings, datatypes,
workflow event types, cronjob parts, commands, translations, schema files and tests. Extensions are distributed as
Composer packages (Anatomy of an extension).
Contents
The directory layout
| Directory | Holds | Registered by |
|---|---|---|
modules/<module>/ | module.php, views, function_definition.php | module.ini [ModuleSettings] ExtensionRepositories[], ModuleList[] |
classes/ | PHP classes | php bin/php/ezpgenerateautoloads.php -e |
autoloads/ | template operator registration | site.ini [TemplateSettings] ExtensionAutoloadPath[] |
design/<design>/ | templates, overrides, stylesheets, scripts, images | design.ini [ExtensionSettings] DesignExtensions[] |
settings/ | *.ini.append.php; siteaccess/<name>/ per siteaccess | being active |
datatypes/, eventtypes/event/ | field types, workflow event types | content.ini, workflow.ini |
cronjobs/ | cronjob scripts | cronjob.ini |
bin/php/ | commands, found as ext:<ext>:<name> | nothing |
share/, sql/<engine>/ | schema and seed data | your install command |
translations/<locale>/ | interface translations | site.ini [RegionalSettings] TranslationExtensions[] |
tests/ | PHPUnit tests | your CI |
Metadata
| File | Content |
|---|---|
extension.xml | <metadata> with name, version, copyright, license, info URL; <dependencies> on other extensions |
ezinfo.php | class <extension>Info with a static info() (Name, Version, Copyright, License, Info_url) |
composer.json | the Composer package, type ezpublish-legacy-extension, with extra.ezpublish-legacy-extension-name |
The about page (/ezinfo/about) reads extension.xml first, so both version fields must agree
(Versions and releases).
Activation and order
site.ini [ExtensionSettings] ActiveExtensions[]activates an extension for every siteaccess;ActiveAccessExtensions[]in a siteaccess's settings activates it there only.- Order matters: the order of
ActiveExtensionsdecides which extension's settings, templates and design files win when two provide the same thing; withExtensionOrdering=enabledthe declared dependencies decide most of the real loading order (Extension loading order). - Setup > Extensions shows and switches them (Extensions guide).
- After activating: regenerate autoloads, clear caches, deploy.
Composer
composer require yourvendor/expdemo:~1.0.0
php bin/php/ezpgenerateautoloads.php -eThe package lands in extension/<name>, the name given by extra.ezpublish-legacy-extension-name. Versions come from Git tags;
a published tag is permanent (Composer packages and Packagist).
autoload.php loads Composer's autoloader, so ordinary libraries required by your extension's composer.json are
available to its classes.
Content classes and demo content travel separately, as packages (.ezpkg) (Migrations and seed data).
Compared with other frameworks
| Framework | Unit | Registered by | Exponential |
|---|---|---|---|
| Symfony | bundle | config/bundles.php | ActiveExtensions[] |
| Laravel | package with a service provider | package discovery | Composer plus ActiveExtensions[] |
| Django | app | INSTALLED_APPS | ActiveExtensions[] |
| Rails | engine, gem | Gemfile, mount | Composer, ActiveExtensions[], modules |
| Spring | starter | auto-configuration | settings in the extension |
Per-siteaccess activation has no common equivalent in other frameworks: one installation can run an extension on one site and not on another.
Related pages
- Your first extension
- Packaging your application as an extension
- Extension development: the book
- 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.