Beamtic's logo

Share via:

_app classes

Doorkeeper apps are often user-developed extensions, but may also include build-in CMS features.


Edited: 2020-09-24 08:42

An App is usually a user-developed extension class that is called by the CMS when a pre-defined URL (Ake. route) is requested by a client; routes are written as part of app definitions which are used by the CMS router.

Apps should be written as extensions to abstract_app_base.php.

Apps must at least include a main() method, and should call exit(); or send a response using the relevant methods. I.e.:

$tpl_content['content'] = '<p>Hallo World</p>';
  'template_content' => $tpl_content + $this->c->get_content(),
  'template_file' => 'general_template.php'

If an app does not exit properly, an exception will be thrown. Of course, developers might choose not to exit an app because they want to return to the composition root; if that is the case, just handle the exception and you will be fine.


Apps are currently located in /lib/_app.


A request path can never be empty; according to the HTTP specification, a client should always at least include a forward slash "/" as the path. If the CMS receives a HTTP request with an empty path, an error is returned.

If a path corresponds with a pre-defined route, the linked app-code will be called.

Routes can currently be defined either as regular expressions or as strings in the composition root (I.e. index.php).

An example app definition, from index.php:

$routes = [
    'strings' => [
        '/' => [
            'class_name' => 'pages\frontpage',
            'request_methods' => ['GET', 'HEAD']
        // The robots.txt file is now created dynamically
        '/robots.txt' => [
            'class_name' => 'pages\robotstxt',
            'request_methods' => ['GET', 'HEAD']
    'regular_expressions' => [
            'pattern' => '/^\/[^\/\.]+$/',
            'class_name' => 'articles\show_article',
            'request_methods' => ['GET', 'HEAD'],
            'allowed_parameters' => ['fbclid'] // Used by Facebook for tracking purposes

In the future it should also be possible to write app definitions as external JSON files.