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.
php artisan module:make mynewaddonwhere mynewaddon is your addon name that is going to be created. Replace it with your own friendly name.
The output of the command will be similar to the following.
Created : /your_mumara_path/Addons/Mynewaddon/module.jsonCreated : /your_mumara_path/Addons/Mynewaddon/Routes/web.phpCreated : /your_mumara_path/Addons/Mynewaddon/Routes/api.phpCreated : /your_mumara_path/Addons/Mynewaddon/Console/Command.phpCreated : /your_mumara_path/Addons/Mynewaddon/Settings/config.phpCreated : /your_mumara_path/Addons/Mynewaddon/Settings/install/v1.0.sqlCreated : /your_mumara_path/Addons/Mynewaddon/Settings/uninstall/uninstall.sqlCreated : /your_mumara_path/Addons/Mynewaddon/Resources/views/index.blade.phpCreated : /your_mumara_path/Addons/Mynewaddon/Resources/lang/en/app.phpCreated : /your_mumara_path/Addons/Mynewaddon/Config/config.phpCreated : /your_mumara_path/Addons/Mynewaddon/composer.jsonCreated : /your_mumara_path/Addons/Mynewaddon/Resources/assets/css/style.cssCreated : /your_mumara_path/Addons/Mynewaddon/Resources/assets/js/app.jsCreated : /your_mumara_path/Addons/Mynewaddon/Resources/assets/sass/app.scssCreated : /your_mumara_path/Addons/Mynewaddon/webpack.mix.jsCreated : /your_mumara_path/Addons/Mynewaddon/package.jsonCreated : /your_mumara_path/Addons/Mynewaddon/json.jsonCreated : /your_mumara_path/Addons/Mynewaddon/menu.jsonCreated : /your_mumara_path/Addons/Mynewaddon//functions.phpCreated : /your_mumara_path/Addons/Mynewaddon/hooks/hooks.phpCreated : /your_mumara_path/Addons/Mynewaddon/Database/Seeders/MynewaddonDatabaseSeeder.phpCreated : /your_mumara_path/Addons/Mynewaddon/Providers/MynewaddonServiceProvider.phpCreated : /your_mumara_path/Addons/Mynewaddon/Providers/RouteServiceProvider.phpCreated : /your_mumara_path/Addons/Mynewaddon/Http/Controllers/MynewaddonController.phpModule [Mynewaddon] created successfully.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/
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.jsYour 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. |
| 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 |
The language file app.php is placed at /Resources/lang/en 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;trans('mynewaddon::app.mynewaddon.page.title')Installing Addon
A default SQL file is placed at /Settings/install/v1.0.sql which executes during the installation. It's important that your SQL file name starts with "v" e.g. v1.0.1.sql or v2.sql etc. The queries you write in this SQL file will execute during the installation process of this addon.
Uninstalling Addon
A default SQL file is placed at /Settings/uninstall/uninstall.sql which executes during the uninstallation process. The uninstallation process runs when the admin navigates to the Addons page, disable this addon and then uninstall it. 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
/Settings/config.php/Settings/install//Settings/install folder caries the following SQL filesThere is a menu.json file in the home directory of the 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
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 or add more PHP files with any names. You can look into Mumara Hooks here.
Example
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 jsIt 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.
| 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().