phpBB

Development Wiki

Difference between revisions of "Developing Extensions"

From phpBB Development Wiki

(directory layout)
m
Line 7: Line 7:
  
 
<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.
 
<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.
 
=== directory layout ===
 
./ext/<vendor>/<extname>/
 
  [[acp]]       
 
  [[adm]]
 
  [[config]]
 
  [[controller]]
 
  [[entity]]
 
  [[event]]
 
  [[exception]]
 
  [[language]]
 
      en
 
      de
 
      nl
 
  [[migrations]]
 
  [[notification]]
 
  [[operators]]
 
  [[styles]]
 
      all
 
        [[template]]
 
        [[theme]]
 
      [[prosilver]]
 
      [[subsilver]]
 
 
Depending on the needs of the extension, some directories may be omitted. For example, the <tt>acp</tt> directory will be needed if the extension allows further configuration using the [[Administration Control Panel]].
 
  
 
=== composer.json ===
 
=== composer.json ===

Revision as of 07:52, 21 November 2014

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>/<extname>

<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 required in order for phpBB to identify your extension as an extension. It is the metadata file containing specific information about your extension. For information on what information goes into the file, please view extension_meta_data. It should be available in the extensions root directory.

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.