Chapter 24. Modules

Table of Contents

Module guidelines
Module architecture
Environment bootstrapping
Exposing URI routes
Adding HTTP API documentation
Adding sections to the Control Panel
Using custom template helpers
Using models

Modules are the most advanced customization method available in dmBridge. They enable the addition of complex new functionality as self-contained units of code.

To write a module, you will need a firm grounding in object-oriented PHP programming, including classes, interfaces, exception handling, class inheritance, accessors, instance methods, and static (class) methods. dmBridge is architected in a way that could be considered more-or-less "standard Java OO" -- at least to the extent that that can be achieved in PHP 5.2 -- and although your modules do not have to work like this, they will need to interface with the dmBridge PHP API, which does.

With a module, all of the following are possible without modifying any built-in dmBridge code:

The process of writing a dmBridge module is fairly complex compared to authoring a template helper or custom viewer. However, the ability exists for developers who require it. As in any other reasonably complex object-oriented API, persistence pays off.

Module guidelines

  • Modules should be built to work in PHP 5.2.

  • Modules should use distinctive class, function, constant, and variable names as necessary in order to avoid naming clashes.

  • Modules should not require any PHP extensions beyond those required by dmBridge (this is suggested but not required).

  • The module's folder should contain all the code necessary to make the module work.