phpBB

Development Wiki

Developing Extensions

From phpBB Development Wiki

Revision as of 19:19, 1 July 2014 by Vse (Talk | contribs)

phpBB 3.1 "Ascraeus" introduces extensions as another way to add new community-contributed features into a phpBB installation. Extensions are different from MODs in that they do not make any file modifications to the core phpBB files. Instead, extensions are entirely contained in their own directories within the ./ext/ directory in the phpBB root.

Getting Started

For an example extension package, please view the following repository: https://github.com/nickvergessen/phpbb-ext-acme-demo

Extensions should be located in the phpBB directory as follows: phpBB/ext/<vendor>/<ext>

<vendor> is the author or group of authors of the extension. Note that vendor and extension directory names may ONLY contain numbers and letters. Underscores, dashes, and other characters are NOT permitted. It is perfectly fine to have an extension named iamanextension.

composer.json

This file is the metadata file containing specific information about your extension. For information on what information goes into the file, please view extension_meta_data.

ext.php

Each extension may also contain a file called ext.php at phpBB/ext/<vendor>/<ext>/ext.php. Here is an example file from an example extension phpBB/ext/example/foobar/ext.php:

namespace example\foobar;

class 
ext extends \phpbb\extension\base
{
}

The class may contain any special (un)installation commands in the methods enable_step(), disable_step() and purge_step(). As it is, these methods are defined in phpbb_extension_base, which this class extends, but you can overwrite them to give special instructions for those cases.

Front-facing Files

While, some extensions perform only background tasks or simply modify a pre-existent page, other extensions may require the inclusion of a front-facing file, which the user is able to access to view information and perform tasks related to the extension. For example, a blog extension needs to display one or more blog entries. To achieve this, we use classes, which are called "controllers". All controllers are mapped with their own routes in the config/routing.yml file. There is one in the main phpBB config directory, but extensions wishing to include a controller must have their own config directory and routing.yml file.

For more information about creating and using a controller for your extension, view the Controller wiki page.