An extension consists of one directory located in phpBB/ext/ - this idea started as Self-contained MODs. All extensions can be viewed in the administration control panel. Extensions can be enabled, disabled and purged. When an extension is enabled its installation and/or update process is executed. This will typically run all [RFC] Migrations the extension supplies. A disabled extension no longer provides any functionality. Its code is not executed, but its data remains in the database. Should the user decide to reenable an extension, the update script will be run in case the database content is outdated. Purging an extension means disabling it as well as deleting all database content relating to the extension.
All plugin mechanisms in phpBB check extensions when they look for available plugins. This includes ACP/UCP/MCP modules, modular cron tasks, search backends, authentication plugins, cache drivers, captcha plugins. It will further include Migrations, Hooks, CSS and template snippets through the Improved Template Engine and other changes.
So extensions will piece the various extendable parts of phpBB together into one comprehensive mechanism. It will be the basis for any form of integrated MOD installation in phpBB 3.1, as discussed in [RFC] MOD Installation and [RFC] MOD Installer.
Why are they called extensions
To avoid ambiguity with MODs. Extensions do not require code modifications. MODs can however ship an extension and should handle their installation and database update requirements through an extension containing migrations. Extension was picked as the prefered term out of a few alternatives for phpBB4 in MODS -> plugins/add-ons/extensions.
How are extensions structured?
An extension can contain any code or resources (data, static files, ...). But for the extension mechanisms to work, some guidelines need to be followed. In the following <ext> is the name of the extension (which must not contain underscores), <name> is an arbitrary name for the individual plugin and <style> is the name of a phpBB style.
- XCP Module:
phpBB/ext/<ext>/xcp/xcp_<name>_module.php
phpBB/ext/<ext>/xcp/xcp_<name>_info.php
- Cron Task:
phpBB/ext/<ext>/cron/<name>_task.php
- Search Backend:
phpBB/ext/<ext>/search/<name>_backend.php
- Cache driver:
phpBB/ext/<ext>/cache/<name>_driver.php
- Authentication plugin:
phpBB/ext/<ext>/auth/auth_<name>.php
- CAPTCHA plugin:
phpBB/ext/<ext>/captcha/<name>_plugin.php
- Hook definitions:
phpBB/ext/<ext>/hook/<name>_hook.php
- Migrations:
phpBB/ext/<ext>/migration/<name>.php
- CSS:
phpBB/ext/<ext>/styles/<style>/theme/<name>.css
- Template:
phpBB/ext/<ext>/styles/<style>/template/<name>.html
- Template-independent Javascript:
phpBB/ext/<ext>/assets/<name>.js
- Admin Template:
phpBB/ext/<ext>/adm/style/<name>.html
- Language:
phpBB/ext/<ext>/language/<language>/<name>.php
How are extensions utilised?
There will be an extension manager which provides the functionality for enabling/disabling/purging extensions. In addition there is an extension finder class that provides a simple interface to locate classes or simply files across all enabled extensions, as shown in these examples:
Code: Select all
$finder = new phpbb_extension_finder($extension_manager);
$cron_task_classes = $finder->directory('/cron')->suffix('_task')->get_classes();
Code: Select all
$finder = new phpbb_extension_finder($extension_manager);
$theme_files = $finder->directory("/styles/$style/theme")->suffix('.css')->get_files();
Patch (WIP): https://github.com/phpbb/phpbb3/pull/329
Ticket: http://tracker.phpbb.com/browse/PHPBB3-10323