Development Wiki

Developing Extensions

From phpBB Development Wiki

Revision as of 17:50, 11 February 2012 by Oleg (Talk | contribs)

phpBB 3.1 "Ascraeus" introduces extensions as another way to add new user-created 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 contained in their own directories within the ./ext/ directory in the phpBB root.

Front-facing Files

Some extensions may require the inclusion of a front-facing file. For example, a blog might need to display all blog entries. This is achieved by using the phpbb_extension_controller_interface. Note: For our example, we will use an extension named "foobar".


To create a "front" file, create a new file in the root of your extension directory ./ext/foobar/ called controller.php. This file must contain a new class called "phpbb_ext_foobar_controller" that implements "phpbb_extension_controller_interface". The class must contain a public function called "handle()", which should take no arguments. Tip: To use common objects within your extension front page, you will need to use the global keyword.


class phpbb_ext_foobar_controller implements phpbb_extension_controller_interface
    public function 
// We have to globalize the phpBB user object if we wish to use it in our extension.
global $user;
// To prevent having to globalize it and others in every method, we can assign it as a class property.
$this->user $user;
// So now if we need to use it, we use $this->user like so:
echo 'Welcome, ' $this->user->data['username'];
// Anything in this function will be executed when the front file is loaded.

You can also include other public and private methods to call within the handle() method.


To load your page, visit