# Modules

Ember comes with a module system that allows for creating new dynamic pages & functionalities.

# Examples

There are a couple example modules available to demonstrate the basic structure & functionality of a module.

# Helper functions

  • Registering a module: Module::registerModule($array). For example
    'name' => 'Example module',
    'identifier' => 'example',
    'version' => '1.0.0',
    'description' => 'An example module for Ember.'
  • Registering an event listener: Module::registerEventListener($event, $listener)
  • Creating a navbar link: Module::addNavbarLink($link). For example
    'icon' => 'fas fa-box',
    'name' => 'Example',
    'url' => '/example',
    'admin_dropdown' => false

# Events

Event listeners provide a way to listen for changes to Ember's models and act on them.

  • available events can be found in app/Events
  • the example module contains an event listener

Visit Laravel's documentation for more information.

# Assets

Module assets (JavaScript & CSS files) located relative to the module's public directory can be loaded from the /modules/{identifier} route by passing the file path to the f URL parameter, for example /modules/example?f=/js/app.js.

The moduleasset and modulemix Twig filters can be used to generate properly formatted URLs for individual files and files compiled with Laravel Mix, respectively. Required arguments are the module's identifier and the file's name.

<script src="{{ 'example'|modulemix('/js/app.js') }}"></script>

# Schema and migrations

  • Database tables are created based on the module's schema in database/migrations/schema.sql, if present.
  • Migrations are located in database/migrations/migrations.php and are structured as follows:
return [
        'version' => '1.0.1',
        'sql' => 'ALTER TABLE Foo ADD COLUMN Bar VARCHAR(20);'

The version number passed to Module::registerModule is used for keeping track of migrations.


Migrations are not run for fresh installations. The schema must be kept up-to-date.


Migrations are run when the storage/updater.lock file is present.

# Localization

Translations are read from resources/lang/en.php relative to the module's root directory. The file is structured as follows:

return [
    'category' => [
        'key' => 'value'

Translations can be used with the lang Twig filter, for example:

<p>{{ 'key'|lang }}</p>

# Module structure

Much like Ember itself, modules consist of routes, controllers and views.

Top-level directories should be named as follows:

  • bootstrap: bootstrapping code and routes
  • database: database schema and migrations
  • module: PHP classes such as controllers, event listeners, middleware and models
  • resources: views, localization files and uncompiled assets