• log out

Modules

As we've seen before, the configuration fields are separated into top-level namespaces, such as "Q" and "First". In fact, almost everything in Qbix is namespaced in this manner. The top-level namespaces are called modules.

Here is a list of places where modules really play a role. Some of these will be explored later in the guide.

  • Config fields are namespaced: $module/foo/bar
  • Event handlers are namespaced: APP_DIR/handlers/$module/...
  • Views are namespaced: APP_DIR/views/$module/...
  • Dynamically-saved files are namespaced: APP_DIR/files/$module/...
  • Classes are namespaced: APP_DIR/classes/$Module/...

Apps and plugins

Your app's name, stored in the Q/app config field, is the name of the module under which you place all your the things introduced by your app's code.

A plugin typically comes with its own module (named after the plugin) under which it packages all the things it introduces. After you finish building an app, you can refactor some of its functionality into a plugin, often with the same name, since the file structure is the same.

Plugins

Plugins are essentially directories which bundle related functionality together. They can include a config file (config/plugin.json), classes, handlers, views, dynamically-saved files, and a web folder, which the Qbix installer creates a symlink to, inside APP_DIR/web/Q/plugins.

Plugins are placed inside the Q_DIR/plugins directory on every environment where they are used. Apps are supposed to indicate the plugins to load in the "Q"/"plugins" config field. This is done by editing the config/app.json file.

The "Q"/"appInfo" config field is where an app tells the Qbix installer which versions of plugins it needs to be installed, and what database connections it will need. Here is an example from the app that's hosting this documentation:

{
  "Q": {
    "app": "QP",
    "appInfo" : {
      "version" : "0.1",
      "compatible": "0.1",
      "requires": {
        "Q": "0.8",
        "Users": "0.8",
        "Streams": "0.8"
      }
    },
    "plugins": ["Users", "Streams"],
    "connections": ["QP"]
    ...

When you create your own plugin, you should also fill out the "Q"/"pluginInfo" config field for the Qbix installer. Here is an example from the Websites plugin, in the config/plugin.json file:

{
  "Q": {
    "pluginInfo": {
      "Websites": {
        "version": "0.8",
        "compatible": "0.8",
        "requires": {"Streams": "0.8"},
        "connections": ["Streams", "Websites"]
      }
    },
    ...