Knowledgebase

Create an Addon

Develop your Mumara addon to enhance the functionality according to your needs. This guide will explain to you how you can develop your own Mumara addon and connect it with Mumara's infrastructure.
 

Create a Sample Addon with Core Files

Follow the steps below to create a new addon with Laravel core files.
 
  1. Access Mumara root location via terminal e.g. PuTTY or similar software
  2. Run the following command
     
    php artisan module:make mynewaddon
    where mynewaddon is your addon name that is going to be created. Replace it with your own friendly name.

    Output

    The output of the command will be similar to the following.
    Created : /your_mumara_path/Addons/Mynewaddon/module.json
    Created : /your_mumara_path/Addons/Mynewaddon/Routes/web.php
    Created : /your_mumara_path/Addons/Mynewaddon/Routes/api.php
    Created : /your_mumara_path/Addons/Mynewaddon/Console/Command.php
    Created : /your_mumara_path/Addons/Mynewaddon/Settings/config.php
    Created : /your_mumara_path/Addons/Mynewaddon/Settings/install/v1.0.sql
    Created : /your_mumara_path/Addons/Mynewaddon/Settings/uninstall/uninstall.sql
    Created : /your_mumara_path/Addons/Mynewaddon/Resources/views/index.blade.php
    Created : /your_mumara_path/Addons/Mynewaddon/Resources/lang/en/app.php
    Created : /your_mumara_path/Addons/Mynewaddon/Config/config.php
    Created : /your_mumara_path/Addons/Mynewaddon/composer.json
    Created : /your_mumara_path/Addons/Mynewaddon/Resources/assets/css/style.css
    Created : /your_mumara_path/Addons/Mynewaddon/Resources/assets/js/app.js
    Created : /your_mumara_path/Addons/Mynewaddon/Resources/assets/sass/app.scss
    Created : /your_mumara_path/Addons/Mynewaddon/webpack.mix.js
    Created : /your_mumara_path/Addons/Mynewaddon/package.json
    Created : /your_mumara_path/Addons/Mynewaddon/json.json
    Created : /your_mumara_path/Addons/Mynewaddon/menu.json
    Created : /your_mumara_path/Addons/Mynewaddon//functions.php
    Created : /your_mumara_path/Addons/Mynewaddon/hooks/hooks.php
    Created : /your_mumara_path/Addons/Mynewaddon/Database/Seeders/MynewaddonDatabaseSeeder.php
    Created : /your_mumara_path/Addons/Mynewaddon/Providers/MynewaddonServiceProvider.php
    Created : /your_mumara_path/Addons/Mynewaddon/Providers/RouteServiceProvider.php
    Created : /your_mumara_path/Addons/Mynewaddon/Http/Controllers/MynewaddonController.php
    Module [Mynewaddon] created successfully.
    Success! Your new module has been successfully created.
    Creating Multiple Addons! If you want to create multiple addons, you can use the command as follow

    php artisan module:make mynewaddon1 mynewaddon2 mynewaddon3

The addon should now be visible in Mumara when you navigate to Setup -> Addons as shown below.



Note: Addon files are created at /your_mumara_path/Addons/Mynewaddon/


Folder Structure

Addons/
  ├── Mynewaddon/
  ├── Config/
      ├── config.php
  ├── Console/
      ├── Command.php
  ├── Database/
      ├── factories/ 
      ├── Migrations/
      ├── Seeders/
          ├── MynewaddonDatabaseSeeder.php
  ├── Entities/
  ├── Events/
  ├── hooks/
      ├── hooks.php
  ├── Http/
      ├── Controllers/
          ├── MynewaddonController.php
      ├── Middleware/
      ├── Requests/
  ├── Jobs/
  ├── Listeners/
  ├── Providers/
      ├── MynewaddonServiceProvider.php
      ├── RouteServiceProvider.php
  ├── Resources/
      ├── assets/
          ├── css/
              ├── style.css
          ├── js/
              ├── app.js
          ├── sass/
              ├── app.scss
      ├── lang/
          ├── en/
              ├── app.php
      ├── views/
          ├── index.blade.php
  ├── Routes/
      ├── api.php
      ├── web.php
  ├── Settings/
      ├── install/
          ├── v1.0.sql
      ├── uninstall/
          ├── uninstall.sql
      ├── config.php
  ├── Tests/
      ├── Feature/
      ├── Unit/
  ├── composer.json
  ├── functions.php
  ├── json.json
  ├── menu.json
  ├── module.json
  ├── package.json
  ├── webpack.mix.js
 

Configuration

Your addon basic configuration file is placed at /your_mumara_path/Addons/Mynewaddon/Settings/config.php. Open the file and you'll find the following parameters.
 
Parameter Description
name Name of the Addon that will appear on the Addons page
vendor Your Company name that should appear as a Vendor
type The type of addon e.g. Integration, Nodes or any helpful category
logo The URL of the addon logo that will appear on the addons page
e.g. https://via.placeholder.com/1200x450
slider The URLs of the addon screenshots that will appear in the preview lightbox
e.g. ['https://via.placeholder.com/1200x450','https://via.placeholder.com/1200x450','//via.placeholder.com/1200x450']
version The version number of this addon
route The URL route of the addon
e.g. mumaradomain.com/mynewaddon/. This must be a single word without spaces or characters except for dashes or underscores e.g route('mynewaddon')
description The description of the addon that will appear on the addons page
read_more URL of the addon details page
install_dir It will be auto-fetched. You don't have to change this value
new_version_url The URL from where Mumara can fetch the latest version number and display the "Update" button on the addons page when there is a new version available.
e.g https://mydomain.com/addons/mynewaddon/version.json
Note! The file extension could be any e.g. json, php, txt, etc. The content of the file should only contain version number in numeric format e.g. 1.0 or 1.1.3 or 3.7.5
update_url The download link of the latest version of the addon when an update is available.
e.g https://mydomain.com/addons/mynewaddon/update.zip
 

Writing Your Language File

The language file is placed in /Resources/lang/en as app.php and sample variables have been already written into it.
 
/**
 * Created by Mynewaddon
 */
/*-------------- mynewaddon ----------------*/
$lang['mynewaddon']['page']['title']       	      = 'Mynewaddon Page';
$lang['mynewaddon']['page']['description'] 	      = 'Description Goes Here 123';
$lang['mynewaddon']['view']['all'] 	              = 'View All';

return $lang;
 

Calling Language

trans('mynewaddon::app.mynewaddon.page.title')
 

Database Queries

Installing Addon

A default SQL file is placed at /Settings/install/v1.0.sql that runs during installation. It's important that your SQL file name starts with "v" e.g. v1.0.1.sql or v2.sql etc. So any queries you write in this SQL file will be run during the installation process of this addon.
 

Uninstalling Addon

A default SQL file is placed at /Settings/uninstall/uninstall.sql that runs during the uninstallation process. The uninstallation process runs when the admin navigates to the Addons page, disable this addon and click on uninstall. So it is advised that you write the equivalent queries that will drop all tables created by your addon.
 

Updating Addon

When the addon is updated by pressing the "Update" button on the addons page, Mumara will perform the following actions
  1. Download the zip file from the "update_url" set in /Settings/config.php
  2. Extract all files to a staging directory
  3. Copy and overwrite the files to your addon folder
  4. Run the SQL files placed at /Settings/install/ after taking the difference between the installed version and the updated version.
    e.g. if you have v1.3 installed that is being updated to v1.7 and the /Settings/install folder caries the following SQL files
    - v1.1.sql, v1.2.sql, v1.3.sql, v1.4.sql, v1.5.sql, v1.6.sql, v1.7.sql
    then the SQL files that will run would be v1.4.sql, v1.5.sql, v1.6.sql, v1.7.sql.
  5. Once the operation is done, the addon will be successfully marked as updated
 

Menu Rendering

There is a menu.json file in the home directory of addon with sample codes inside. Just add to the menu items as explained in the sample codes below
 
[{
  "title": "Mynewaddon Addon",
  "icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"24px\" height=\"24px\" viewBox=\"0 0 24 24\" version=\"1.1\" class=\"kt-svg-icon\">\r\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n <rect id=\"bound\" x=\"0\" y=\"0\" width=\"24\" height=\"24\"></rect>\r\n <path d=\"M10.5,5 L19.5,5 C20.3284271,5 21,5.67157288 21,6.5 C21,7.32842712 20.3284271,8 19.5,8 L10.5,8 C9.67157288,8 9,7.32842712 9,6.5 C9,5.67157288 9.67157288,5 10.5,5 Z M10.5,10 L19.5,10 C20.3284271,10 21,10.6715729 21,11.5 C21,12.3284271 20.3284271,13 19.5,13 L10.5,13 C9.67157288,13 9,12.3284271 9,11.5 C9,10.6715729 9.67157288,10 10.5,10 Z M10.5,15 L19.5,15 C20.3284271,15 21,15.6715729 21,16.5 C21,17.3284271 20.3284271,18 19.5,18 L10.5,18 C9.67157288,18 9,17.3284271 9,16.5 C9,15.6715729 9.67157288,15 10.5,15 Z\" id=\"Combined-Shape\" fill=\"#000000\"></path>\r\n <path d=\"M5.5,8 C4.67157288,8 4,7.32842712 4,6.5 C4,5.67157288 4.67157288,5 5.5,5 C6.32842712,5 7,5.67157288 7,6.5 C7,7.32842712 6.32842712,8 5.5,8 Z M5.5,13 C4.67157288,13 4,12.3284271 4,11.5 C4,10.6715729 4.67157288,10 5.5,10 C6.32842712,10 7,10.6715729 7,11.5 C7,12.3284271 6.32842712,13 5.5,13 Z M5.5,18 C4.67157288,18 4,17.3284271 4,16.5 C4,15.6715729 4.67157288,15 5.5,15 C6.32842712,15 7,15.6715729 7,16.5 C7,17.3284271 6.32842712,18 5.5,18 Z\" id=\"Combined-Shape\" fill=\"#000000\" opacity=\"0.3\"></path>\r\n </g>\r\n</svg>",
  "url": "mynewaddon/addon",
  "hasChild": true,
  "childrens": [
    {
      "title": "Mynewaddon Child 1",
      "icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"24px\" height=\"24px\" viewBox=\"0 0 24 24\" version=\"1.1\" class=\"kt-svg-icon\">\r\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n <rect id=\"bound\" x=\"0\" y=\"0\" width=\"24\" height=\"24\"></rect>\r\n <path d=\"M10.5,5 L19.5,5 C20.3284271,5 21,5.67157288 21,6.5 C21,7.32842712 20.3284271,8 19.5,8 L10.5,8 C9.67157288,8 9,7.32842712 9,6.5 C9,5.67157288 9.67157288,5 10.5,5 Z M10.5,10 L19.5,10 C20.3284271,10 21,10.6715729 21,11.5 C21,12.3284271 20.3284271,13 19.5,13 L10.5,13 C9.67157288,13 9,12.3284271 9,11.5 C9,10.6715729 9.67157288,10 10.5,10 Z M10.5,15 L19.5,15 C20.3284271,15 21,15.6715729 21,16.5 C21,17.3284271 20.3284271,18 19.5,18 L10.5,18 C9.67157288,18 9,17.3284271 9,16.5 C9,15.6715729 9.67157288,15 10.5,15 Z\" id=\"Combined-Shape\" fill=\"#000000\"></path>\r\n <path d=\"M5.5,8 C4.67157288,8 4,7.32842712 4,6.5 C4,5.67157288 4.67157288,5 5.5,5 C6.32842712,5 7,5.67157288 7,6.5 C7,7.32842712 6.32842712,8 5.5,8 Z M5.5,13 C4.67157288,13 4,12.3284271 4,11.5 C4,10.6715729 4.67157288,10 5.5,10 C6.32842712,10 7,10.6715729 7,11.5 C7,12.3284271 6.32842712,13 5.5,13 Z M5.5,18 C4.67157288,18 4,17.3284271 4,16.5 C4,15.6715729 4.67157288,15 5.5,15 C6.32842712,15 7,15.6715729 7,16.5 C7,17.3284271 6.32842712,18 5.5,18 Z\" id=\"Combined-Shape\" fill=\"#000000\" opacity=\"0.3\"></path>\r\n </g>\r\n</svg>",
      "url": "#"
    },
    {
      "title": "Mynewaddon Child 2",
      "icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"24px\" height=\"24px\" viewBox=\"0 0 24 24\" version=\"1.1\" class=\"kt-svg-icon\">\r\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n <rect id=\"bound\" x=\"0\" y=\"0\" width=\"24\" height=\"24\"></rect>\r\n <path d=\"M10.5,5 L19.5,5 C20.3284271,5 21,5.67157288 21,6.5 C21,7.32842712 20.3284271,8 19.5,8 L10.5,8 C9.67157288,8 9,7.32842712 9,6.5 C9,5.67157288 9.67157288,5 10.5,5 Z M10.5,10 L19.5,10 C20.3284271,10 21,10.6715729 21,11.5 C21,12.3284271 20.3284271,13 19.5,13 L10.5,13 C9.67157288,13 9,12.3284271 9,11.5 C9,10.6715729 9.67157288,10 10.5,10 Z M10.5,15 L19.5,15 C20.3284271,15 21,15.6715729 21,16.5 C21,17.3284271 20.3284271,18 19.5,18 L10.5,18 C9.67157288,18 9,17.3284271 9,16.5 C9,15.6715729 9.67157288,15 10.5,15 Z\" id=\"Combined-Shape\" fill=\"#000000\"></path>\r\n <path d=\"M5.5,8 C4.67157288,8 4,7.32842712 4,6.5 C4,5.67157288 4.67157288,5 5.5,5 C6.32842712,5 7,5.67157288 7,6.5 C7,7.32842712 6.32842712,8 5.5,8 Z M5.5,13 C4.67157288,13 4,12.3284271 4,11.5 C4,10.6715729 4.67157288,10 5.5,10 C6.32842712,10 7,10.6715729 7,11.5 C7,12.3284271 6.32842712,13 5.5,13 Z M5.5,18 C4.67157288,18 4,17.3284271 4,16.5 C4,15.6715729 4.67157288,15 5.5,15 C6.32842712,15 7,15.6715729 7,16.5 C7,17.3284271 6.32842712,18 5.5,18 Z\" id=\"Combined-Shape\" fill=\"#000000\" opacity=\"0.3\"></path>\r\n </g>\r\n</svg>",
      "url": "#"
    },
    {
      "title": "All Childs",
      "icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"24px\" height=\"24px\" viewBox=\"0 0 24 24\" version=\"1.1\" class=\"kt-svg-icon\">\r\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\r\n <rect id=\"bound\" x=\"0\" y=\"0\" width=\"24\" height=\"24\"></rect>\r\n <path d=\"M10.5,5 L19.5,5 C20.3284271,5 21,5.67157288 21,6.5 C21,7.32842712 20.3284271,8 19.5,8 L10.5,8 C9.67157288,8 9,7.32842712 9,6.5 C9,5.67157288 9.67157288,5 10.5,5 Z M10.5,10 L19.5,10 C20.3284271,10 21,10.6715729 21,11.5 C21,12.3284271 20.3284271,13 19.5,13 L10.5,13 C9.67157288,13 9,12.3284271 9,11.5 C9,10.6715729 9.67157288,10 10.5,10 Z M10.5,15 L19.5,15 C20.3284271,15 21,15.6715729 21,16.5 C21,17.3284271 20.3284271,18 19.5,18 L10.5,18 C9.67157288,18 9,17.3284271 9,16.5 C9,15.6715729 9.67157288,15 10.5,15 Z\" id=\"Combined-Shape\" fill=\"#000000\"></path>\r\n <path d=\"M5.5,8 C4.67157288,8 4,7.32842712 4,6.5 C4,5.67157288 4.67157288,5 5.5,5 C6.32842712,5 7,5.67157288 7,6.5 C7,7.32842712 6.32842712,8 5.5,8 Z M5.5,13 C4.67157288,13 4,12.3284271 4,11.5 C4,10.6715729 4.67157288,10 5.5,10 C6.32842712,10 7,10.6715729 7,11.5 C7,12.3284271 6.32842712,13 5.5,13 Z M5.5,18 C4.67157288,18 4,17.3284271 4,16.5 C4,15.6715729 4.67157288,15 5.5,15 C6.32842712,15 7,15.6715729 7,16.5 C7,17.3284271 6.32842712,18 5.5,18 Z\" id=\"Combined-Shape\" fill=\"#000000\" opacity=\"0.3\"></path>\r\n </g>\r\n</svg>",
      "url": "mynewaddon/addon"
    }
  ]
}]

The sample above will add the following menu items
  • Addons
    • Mynewaddon Addon
      • Mynewaddon Child 1
      • Mynewaddon Child 2
      • All Childs
 

Hooks

Hooks allow you to execute your own code upon occurring events inside Mumara. You'll find a sample hook.php file inside /hooks folder of the addon. Write your hook codes into this file to add more PHP files with any names. You can look into Mumara Hooks here.

Example

<?php

use App\Classes\AddonHooks;

/****** Hook to append addon js to footer */
AddonHooks::add_hook('hook_name', function($args) {

    return "<script>console.log('Mynewaddon')</script>";
    
    },'addons_script'); // addons_script is the section in footer for js
 

Dependencies and Licensing

It allows you to make your addon installation and update process more powerful, user-friendly, and secure by adding dependency checks before initiating the process. This process can also be used if you want the process to go through your external licensing system before starting the operation.

In your addon folder e.g. /Mynewaddon, you'll find a file functions.php that carries these functions.
 

Supported Functions

Function Description
checkDependency The code here runs as a dependency checker before proceeding further. (optional)
checkLicense The code here will run after the dependency checker and it's used to verify the license from the remote location. (optional)
update_addon After getting a success response from checkDependency and checkLicense, Mumara will fetch the update URL from this function and start the update.
install_addon After getting a success response from checkDependency and checkLicense, Mumara will continue with the installation process.

The functions checkDependency() and checkLicense() should start from your addon name as a prefix e.g. mynewaddon_checkDependency().

 
Help! For any help with creating an addon, we suggest you open a community topic.