Search for Resources and Solutions

Midrub Apps Structure

In this article i will explain the structure of the Midrub's app and will show in a video how to create a simply app in Midrub. You can learn here how to create your app for Midrub.

The Midrub App's structure is simply, below you can see the interface:



interface Apps {

    /**
     * The public method check_availability checks if the app is available
     *
     * @return boolean true or false
     */
    public function check_availability();
    
    /**
     * The public method user loads the app's main page in the user panel
     * 
     * @since 0.0.7.9
     * 
     * @return void
     */
    public function user();
    
    /**
     * The public method ajax processes the ajax's requests
     * 
     * @since 0.0.7.9
     * 
     * @return void
     */
    public function ajax();

    /**
     * The public method rest processes the rest's requests
     * 
     * @param string $endpoint contains the requested endpoint
     * 
     * @since 0.0.7.9
     * 
     * @return void
     */
    public function rest($endpoint);
    
    /**
     * The public method cron_jobs loads the cron jobs commands
     * 
     * @since 0.0.7.9
     * 
     * @return void
     */
    public function cron_jobs();
    
    /**
     * The public method delete_account is called when user's account is deleted
     * 
     * @param integer $user_id contains the user's ID
     * 
     * @since 0.0.7.9
     * 
     * @return void
     */
    public function delete_account($user_id);
    
    /**
     * The public method hooks contains the app's hooks
     * 
     * @param string $category contains the hooks category
     * 
     * @since 0.0.7.9
     * 
     * @return void
     */
    public function load_hooks($category);

    /**
     * The public method guest contains the app's access for guests
     * 
     * @since 0.0.7.9
     * 
     * @return void
     */
    public function guest();
    
    /**
     * The public method app_info contains the app's info
     * 
     * @since 0.0.7.9
     * 
     * @return array with app's info
     */
    public function app_info();
    
}

The app's methods:

  • check_availability - verifies if the app is available. Please use inside the option verification, plan verification and team't verification.
  • user - displays the app's content. This in my apps loads the user's controller with view but you can use any file you want.
  • ajax - processes all ajax calls for this app. I've invented the way and it makes the ajax calls easy to manage.
  • cron_jobs - has all methods to run when the cron job is called. 
  • delete_account - when user or admin deletes a user account, is called this method and you can decide what will be deleted in your app.
  • load_hooks - is called before load the app's content and there you can add all your hooks. The category allows to filter the hooks to load when them are required, not even register if isn't required. 
  • guest - is used to load app's content which will be available to the public.
  • app_info has the app's info.


Please be careful with array returned by the app_info method:



        return array(
            'app_name' => '', // App Name
            'app_slug' => '', // App Slug, please remember should be unique
            'app_icon' => '', // App icon should be a font icon
            'version' => '', // App version, i'm using it to clear the styles and js
            'min_version' => '', // The supported version, soon will be disabled automatically 
            'max_version' => '' // Midrub will be updated if version isn't supported.
        );

Your app should have a class which will implement the interface use MidrubBase\User\Interfaces\Apps.

The video below shows how to create a Midrub's App:

To understand how to display the content in a Midrub's App please watch the video below:



Was this article helpful?